0
what is the difference between return and print function?
how to use the value stored in return function?
2 Respostas
+ 2
return is when you want something, like data or a value, out of a method. void methods don't return anything, but can certainly DO stuff (like print to the console or manipulate data).
Think of the difference between withdrawing cash from an ATM vs checking your balance. In the first case our withdraw() function returns an int of money, or perhaps a Currency object. The checkBalance() method has a void return type, but it prints stuff to the screen
+ 1
an extra reference for the above answer
https://stackoverflow.com/a/750148/7887883