• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing methods in other classes

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[deleted as not relevant to this thread.]
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sowm Herur
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Temporarily closing this thread. Hope to reopen it in a few minutes.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Raghavan.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My Pleasure CR!
 
Lee Kian Giap
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats indeed great!
 
reply
    Bookmark Topic Watch Topic
  • New Topic