Results 1 to 4 of 4
Thread: executing a method in main class
- 07-19-2008, 03:19 AM #1
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
executing a method in main class
Hello I need help. I'm learning Java and have been stuck on this for the past few days (I hope I will laugh at this one day!)
the problem I'm having is executing a method belonging to a class within the same package inside the main class's main method. Can you please make some suggestions.
Thank youLast edited by rangers27; 07-19-2008 at 05:40 AM.
- 07-19-2008, 04:08 AM #2
If you are getting compiler error message, please copy and paste them here.
Which Owner class method are you trying to execute?
You've defined the Owner class as a "singleton". Is that part of the assignment?
To get a reference to the Owner class you'd use the static method in Owner that returns a reference to it:
Owner ownr = Owner.getInstance(); // get reference to Owner
Then to call a method would be like with any other class:
ownr.<methodname>[(<args>)];
- 07-19-2008, 04:53 AM #3
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
Norm thank you for your reply. Yes the Singleton is part of the intent. The method I'm trying to execute is getOwner so it would return the string "what can I do for you".
The error I keep getting is type Owner cannot be resolved. I tried to cast Owner but the error continues.
Once again thank you for your help.
- 07-19-2008, 05:04 AM #4
Member
- Join Date
- Jul 2008
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Calling main method
By eva in forum New To JavaReplies: 7Last Post: 11-06-2009, 01:37 PM -
How to create main class link to another two class?
By pearllymary78 in forum New To JavaReplies: 6Last Post: 07-16-2008, 11:02 PM -
A query about main method
By mew in forum New To JavaReplies: 2Last Post: 12-24-2007, 09:44 AM -
Private main method
By bugger in forum New To JavaReplies: 1Last Post: 12-21-2007, 09:45 AM -
main method
By eva in forum New To JavaReplies: 5Last Post: 12-19-2007, 09:25 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks