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 08-03-2007, 04:49 PM
Member
 
Join Date: Jul 2007
Posts: 41
gabriel is on a distinguished road
there is no return statement
an error tell me that there is no return statement .
I don't know the cause

Code:
public class FirstTest { public static void main() { int one = 0; int two = 2; add(a, b); } public static int add(int one, int two) { int c = a + b; } }
what's the problem?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-03-2007, 08:24 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
public static int add(int one, int two) { int c = a + b; return c; }
Every method in java must have a return type in its method signature. The add method has a return type of int which means that the method must return an int. i can call the add method with two arguemnts and get the sum of them back, it will return the sum to me: int x = add(5, 6);
The type returned from the method must match the return type declared in the method signature.
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
import statement. diRisig New To Java 2 02-08-2008 02:34 AM
Using Prepared Statement Java Tip Java Tips 0 02-06-2008 11:22 AM
Help with if statement carl New To Java 1 08-06-2007 09:53 AM
Statement or Prepared Statement ? paty Database 3 08-01-2007 06:45 PM
If Statement aDrizzle New To Java 4 07-08-2007 10:55 PM


All times are GMT +3. The time now is 10:57 PM.


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