+ 1
what's returning a value....??
3 Answers
+ 2
Returning a value in JAVA is like sending some value from one class to another class instead of calculating the same value in the latter case again, provided proper object is being created in the latter class. Not only that the return value can also be invoked in some other class and thus we don't have to do a single job repeatedly again and again. Thus reducing and saving a lot of time and energy. In JAVA, C++ etc. returning value from a function is very efficient and beneficial. So do prefer returning value to simplify your work.
+ 2
Returning a value lets a function give a value â like a number, boolean, or string - back to your program.
For example, if I have a function like:
public static bool isPositive (int number) {
if ( number > 0 ) { return true; }
else { return false; }
}
then I can say something like this:
bool isMyNumberPositive = isPositive(myNumber);
The isPositive method RETURNS a true or false value, which means it can "give" that value to the variable isMyNumberPositive.
0
thank you........