+ 2
Hi, I started learning Java and I have a question, I can not understand the use of the return command, thank you .
Java
3 Respostas
+ 3
It is used for giving value when we call function in code
+ 1
in short and simple for example if the method was void you don't need that and you may define output with system.out.println() but if it was something like <<public int integer(){ }>> you need to use it otherwise how you want to define that what do you want from that method as output and the return type most be the same as variable type.
0
it just leave some value that u can use after u run that method
example:
int func () { return 2; }
int num = func(); //call func,func run then give u back number 2
now num will equal to 2