+ 1

Wht does this work?

How come this: class MyClass { static void sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { sayHello(); } } // Outputs "Hello World!" Works even though I didn't include the class name?

7th Dec 2017, 12:57 AM
Unidentified
Unidentified - avatar
1 Antwort
+ 2
It is within the same class so doesn't need to called via the class name. It's optional in this case.
7th Dec 2017, 1:05 AM
John Wells
John Wells - avatar