Return Java Keyword

Ads
 

Return Java Keyword

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

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

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);

}

Ads

Ads