+ 2
Operations in Java
I'm learning about operators in Java; I've learned about the modulo operator, which takes the remainder of division. Here's the code for the "Try it Yourself": public class Program { public static void main(String[] args) { int value = 23; int res = value % 6; System.out.println(res); } } Yet I thought, "void," meant that a method does not return a value. Is "res," which is in this case, 5, a return value?
1 Réponse
+ 1
Void means as you said, that the method does not return anything, and by returning anything means nothing that can be stored in a variable to be used on another algorithm. Please consider that the method in your example is the "main" method, which is the entry point of an application in java, and by default it must be declared public, static and void. It'll become clearer as you keep progressing in your learning. Good luck Webber.