Please, show me How to return to a calling void method within or without using the RETURN (in java).
Thanks

Recommended Answers

I guess you need to return from a method whose return type is declared as void. Just put the return keyword without specifying anything after it.

public void check(){
// code for the method
return;
}
Jump to Post

All 3 Replies

I guess you need to return from a method whose return type is declared as void. Just put the return keyword without specifying anything after it.

public void check(){
// code for the method
return;
}

i think you need to return something from calling method...

like below..

public static string getUserName(parameters)
{
//your code//

return string;
}

you calling thid method in main() method,

public static void main(string args[])

{
String username=getUserName(parametesr);
}

@OP: On reading your question again, I guess you are asking for something different. Elaborate on your question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.