+ 1

what's returning a value....??

25th Sep 2016, 5:13 PM
Dinuka
3 Respuestas
+ 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.
25th Sep 2016, 6:50 PM
Rituraj Datta
Rituraj Datta - avatar
+ 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.
25th Sep 2016, 11:32 PM
An Owomoyela
An Owomoyela - avatar
0
thank you........
26th Sep 2016, 3:32 PM
Dinuka