How do I declare a static variable inside the Main method?

Obviously, no, we can’t.

In Java, static means that it’s a variable/method of a class, it belongs to the whole class but not to one of its certain objects.

This means that static keyword can be used only in a ‘class scope’ i.e. it doesn’t have any sense inside methods.

Leave a Comment