+ 1
Static methods
can any one explain to me why the methods in the main class should be a static methods
1 Odpowiedź
+ 6
A static method is a method that we can access it without creating an object of that class that method is in , so when you compile your code the compiler looks for the main method so it must be declared as static othervise the compiler can't access it without object so a compile time error will ocur.
Beacuse of that we need to declare the main class a s static so the compiler can access it without creating an object