-8

Onetime I forgot to put the static keyword for the main method in my java class. And the program did not work . So the question is why we always need to mark the main method as static?

Ben
  • 1,414
  • 2
  • 13
  • 18

1 Answers1

-2

When you call any method from the same class you have the main you need to make it static or build an instance of that class new Class().method(). In the case of public static void main (String[] args) it's explained here link

T4l0n
  • 595
  • 1
  • 8
  • 25