Return Java Keyword

The return is a keyword defined in the java programming language.

Ads

Tutorials   

Return Java Keyword

     

The return is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java programming language likewise the return keyword indicates the following :  

--  The return keyword is always used with a method only to specify that the method is going to return something.
--  The return keyword forces a method to return to the method calling it.
--  The return keyword passes a value back to the calling method after matching the
return type of the called method.
-- 
If there is void return type it means it is returning nothing back to the called function. 
-- 
If the method has a non−void return type, the return statement must have an argument of the same or a compatible type.

Using a return Keyword within a class, with a method

A method returning nothing

public void Void_Method()

{

<statements>

return;

}

A method returning a String

public String String_Method()

{

String s = "its Ridiculous to do such kind of work, people here are just aim less";

return s;

}

A method returning an Int value 

public int Int_Method()

{

int i = 5;

return(i);

}

Advertisements

Share on Google+Share on Google+

Return Java Keyword

Posted on: November 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Return Java Keyword  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:2
hiro
August 19, 2011
return

How to use return in method
manojkumar
September 1, 2011
return

i have one doubt .. return keyword will print that value?

Ads

 

Ads