Hey guys, sorry to bring this topic into Ranch Office inadvertently ...
Sowm Herur,
I usually point out ideas to others at job, which might seems to be a bit aggressive. Well, if my words really give bad feeling to you, I really apologize.
Lets shake hand and moving forward.
Hope you understand, now I try to explain my previous post which might be misunderstand as a criticism.
From your question, I can say that you have a problem of understanding how really Java work as an object-oriented (OO) programming language, which is totally different from other language such as C or VB where calling a method is just simply invoked with the method name.
Also from the question, "package" have nothing to do with invoking a method (or in OO, means sending message from one object to another object), "package" will affect the access control of your class or member.
I said this because, from your question showing that you are wondering whether you need to create an instance to access method is depend on where the two participate classes located.
The Idea I am trying to give is no matter where is your classes (same package or different package),
(a) To access a non-static method , it is a must to have an instance, i.e. instanceOfClass.method(...)
If you access the method in other class, you need to create an instance
If you access the method in the class which it defined (not in a static method) , you don't need to create an instance because you already have "this" which refer to an object of current class. In this case, you can also create an instance if your purpose is not to use "this", the discussion will go into design issue (e.g. Category has a sub-Category)
(b) To access a static method, it can be access through Class.method(...) , or through instance which is instanceOfClass.method(...)
In the above explanation, (a) shows object_X is sending message to object_Y, object X is the place where you invoke the method i.e. object_Y.method(...) , this is what it mean by sending message. So, in Java or said OO programming world, bunch of object is talking to each other by sending message.
So, what I really hope and point you to a direction that not memorising how to invoke a method, but understanding how things work differently in OO world, because I see your confusion in OO and non-OO world and mess up with the usage of "package"
And from your code, clearly show that you did not put your effort to compile and test it ... can you explain whether is it a class ? abstract class ? or interface ? ... if it is a class, how come the method signature end with (); , which is an abstract method without implementation ?
If you keep on with this attitude, you are not able to pick up Java knowledge, not even the fundamental. I suggest you to have a good reference book with you rather than simply study in a mess, and please clarify yourself the concept of class and object.
For this part, as I read back my
word , really really a bit aggressive. Well, I think I was in emotion at that time after reading quite some post which reflect my behavior when I was a beginner of not putting
enough effort.
Hope my effort here will bring back a peace to the forum.
For all rancher,
Lets shake hand, and lets stop standing on either side, everyone have emotion and the most appreciate is to solve the problem.
"It takes two to make a quarrel" (which means one hand couldn't make a clap), so let us move forward.
I learn a lesson on soft skill which is the area that I need improvement on, thanks Sowm Herur, so I hope that you will still accept my help in future, and I also will need your help in this forum on area that you expertise in.