+ 1
Why doesn't 5 get outputed?
class MyClass { static int ReturnFive() { return 5; } } public class Caller { public static void main(String[ ] args) { MyClass.ReturnFive(); } }
4 odpowiedzi
+ 5
The return statement makes it so there is a 5 ready to be assigned or otherwise used. You, then, must tell the computer how to use it. In your program as written, you told the computer to toss it.
+ 3
Try...
System.out.println(MyClass.ReturnFive());
It helps to ask for output.
+ 3
Nothing is done automatically. You must code what you want done and, if you fail to code it perfectly, it will run how you coded it, not how you wanted it.
+ 3
Thank you very much