Results 1 to 5 of 5
Thread: Calling a Method
- 09-24-2012, 07:37 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 54
- Rep Power
- 0
- 09-24-2012, 08:09 PM #2
Re: Calling a Method
To call a method in another class, you need a reference to an instance of the other class, then code it like this:
refToClass.theMethod(<any args here>);
See also post#18 on this thread: If else problemLast edited by Norm; 09-24-2012 at 08:30 PM. Reason: clarify
If you don't understand my response, don't ignore it, ask a question.
- 09-24-2012, 08:14 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 54
- Rep Power
- 0
Re: Calling a Method
When you said in a class do you mean inside the class that code is in or do you mean from another class?
- 09-24-2012, 08:27 PM #4
Re: Calling a Method
There are two locations for code in this discussion. One is the location from which the call is being made and the other location is the code that is being called. I was talking about the case where the calling code was in one class and the called code was in another class.
If the two locations are in the same class, then the reference to the current class would be: this which is the default and can be left off.If you don't understand my response, don't ignore it, ask a question.
- 09-24-2012, 08:35 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 54
- Rep Power
- 0
Similar Threads
-
Thread problem, calling method in run method
By majk in forum Threads and SynchronizationReplies: 4Last Post: 09-27-2010, 11:40 AM -
Calling The main method from another method
By SwissR in forum New To JavaReplies: 3Last Post: 07-27-2010, 11:03 AM -
Calling a method
By mnki23 in forum New To JavaReplies: 21Last Post: 11-06-2009, 09:10 PM -
calling method from main method
By bob_bee in forum New To JavaReplies: 4Last Post: 10-02-2009, 05:30 PM -
Calling a method in a different class from within a method problem
By CirKuT in forum New To JavaReplies: 29Last Post: 09-25-2008, 07:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks