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 12-17-2007, 06:48 AM
Member
 
Join Date: Nov 2007
Posts: 12
bluegreen7hi is on a distinguished road
Calling Methods
Hi, I have a question that is probably pretty simple to most of you, but I am confused. What is the correct way to make the main method call another method? For instance, if I want the main method to execute method 1 then method 2, how would I go about typing that out?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-17-2007, 07:18 AM
Member
 
Join Date: Dec 2007
Posts: 26
apfroggy0408 is on a distinguished road
Code:
public static void main(String args[]); computemethod(); <----- Calls first method computenextmethod(); <----- Calls second method public void computemethod() { Method 1. } public void computenextmethod() { Method 2. }
hope that helps
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-17-2007, 07:34 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,609
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
You have to think about parameters and return values of a method as well. And also you can't referenced non-static method from a static method also.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-17-2007, 08:22 AM
Member
 
Join Date: Dec 2007
Posts: 8
newmember is on a distinguished road
In order to reference non-static methods , you will have to create object of the class in main and call those methods.
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
method calling? frejon26 New To Java 4 01-25-2008 05:38 AM
Constructor calling ravian New To Java 2 12-22-2007 08:53 PM
Calling Java methods form Python mew Advanced Java 1 12-21-2007 04:30 PM
Problems with readLine() and calling methods peachyco New To Java 2 11-24-2007 09:44 AM
need help calling methods lowpro New To Java 2 11-15-2007 11:53 AM


All times are GMT +3. The time now is 03:51 AM.


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