Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-19-2008, 05:19 AM
Member
 
Join Date: Jul 2008
Posts: 3
rangers27 is on a distinguished road
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 you

Last edited by rangers27 : 07-19-2008 at 07:40 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-19-2008, 06:08 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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>)];
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-19-2008, 06:53 AM
Member
 
Join Date: Jul 2008
Posts: 3
rangers27 is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-19-2008, 07:04 AM
Member
 
Join Date: Jul 2008
Posts: 3
rangers27 is on a distinguished road
thank you
Norm thank you. I took out the cast and did what you advised and it worked? Thank you for your help
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create main class link to another two class? pearllymary78 New To Java 6 07-17-2008 01:02 AM
A query about main method mew New To Java 2 12-24-2007 11:44 AM
Calling main method eva New To Java 1 12-22-2007 02:14 PM
Private main method bugger New To Java 1 12-21-2007 11:45 AM
main method eva New To Java 5 12-19-2007 11:25 AM


All times are GMT +3. The time now is 01:06 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org