+ 1
Why do we need to declare a method with static and void?
class MyClass { static sayHello() { System.out.println("Hello World!"); } public static void main(String[ ] args) { sayHello(); } }
1 Answer
+ 2
We declare methods static so they can be accessed without holding an instance of an Object based on that class.
And
We declare methods void as the method is not returning any value.