Answer to Question #25341 in Java | JSP | JSF for hly

Question #25341
What "RETURN" statement and How to use "RETURN" statement in Java when public a method or class ?
1
Expert's answer
2013-03-01T02:42:31-0500
There are two ways to use this return: 1)we can return the methodthat is method executes a block and returns (in any case, something will
return. The only question that you need or what that is)

example:
public static String getText (int index) {
return"Hello World". substring (index); }

public static void main(String[] args)
{
Stringtext=getText(0);//getText(0) returns "Hello World"
System.out.println( text);//prints result }

2) in the second case we can use return to "undo" ablock.example

void setText ()
{
if (foo) return;
this.text ="Hello World";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS