I suppose this is more a question about language theory than anything else. Why is the first statement in main legal, when the second is not? Don\'t they evaluate to be the
In the first statement you are actually calling a function and second statement doesn't give any value. Incase you want to process the return value, you need to call a variable for return type
Eg:
public class Main {
public static void main(String[] args) {
int n = foo();
//do whatever you want with return
}
public static int foo() {
return 0;
}
}