GeeCON Prague 2014*
The moose likes Ranch Office and the fly likes Accessing methods in other classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "Accessing methods in other classes" Watch "Accessing methods in other classes" New topic
Author

Accessing methods in other classes

Sowm Herur
Ranch Hand

Joined: Jul 07, 2008
Posts: 32
[deleted as not relevant to this thread.]
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
Dear Sowm Herur,

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.

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.

ALL THE BEST


SCJP 6, SCWCD 5, SCBCD 5
Sowm Herur
Ranch Hand

Joined: Jul 07, 2008
Posts: 32
Hi Lee,

This is not the kind of response i expected from you.
If you have patience to explain it to the beginners of java please respond, or else please don't post such rude replies.This is not all professional behaviour from you.
I don't want help from people like you.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Temporarily closing this thread. Hope to reopen it in a few minutes.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Please continue all discussion about "accessing methods" in this "Beginning Java" thread. I shall edit posts to delete what should be discussed there.

Discussion about tone of reponses, please, here in Ranch Office.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Sowm Herur, if I posted something like the tone of your last post I would be ashamed of myself. Lee Kian Giap's post was definite and assertive. It is a warning that you will not learn, and a rebuke for the amount of effort you do or don't put into your work. some of us here believe that Lee Kian Giap is correct.

Also I saw nothing rude in that post, only in your reply.

You need to take notice of what you have been told; if I thought not putting much more effort into my work, I would be looking for a different job altogether.

I think you also owe Lee Kian Giap an apology for the tone of your posting.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Yes Campbell. Looks like Sowm Herur got agitated due to the fact of not just getting the expected response/answer to the query!

I agree with you! -- Correct me if the latest/new forum rules does NOT allow these kinda thought sharing and if so, please delete this post of mine!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Thank you, Raghavan.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

My Pleasure CR!
Lee Kian Giap
Ranch Hand

Joined: Jan 23, 2008
Posts: 213
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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Thank you very much, Lee Kian Giap. Very good of you to offer to shake hands

Robust, maybe, a bit aggressive, maybe, but no more than that. I showed your post to my wife earlier, and she agreed that you didn't say anything rude.
Please copy what you posted about "accessing methods" in the corresponding "Beginning Java" thread.
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
I too don't think that Lee was rude in his post and appreciate his humbleness.

Between, Thanks for explaining the design for this strucutre.

Cheers

Regards
Patricia
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39066
    
  23
Maybe I was harsh with Sowm Herur . . . if so, I am very sorry.

Sowm has sent me an apology . . . for which all credit is due
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Thats indeed great!
 
GeeCON Prague 2014
 
subject: Accessing methods in other classes