Why is the main method static in java?

To understand this first you need to know why do we create static methods and how do we call them learn about static methods at :

Main method is declared static because static methods do not need any instance to get themselves called. Java is Object Oriented language so it is necessary to declare the  main method as static because their are some conditions in which we don’t want to create the object for example if we want to do simple programming without using Concepts of OOP then their is no way to call the main method but by declaring it static. The code below will help you understand.

  public class MyClass{

public void main(String arguments[]){




The above code generates an error: main method is not static please define the main method as:
   public static void main(String[] args)
But when the main is made static this code runs fine and gives the output: codeheaven.wordpress.com

          If you find my answer intresting and easy to understand invite your friends to read this and Don’t Forget to Like and give your feedback and suggesions 🙂


One thought on “Why is the main method static in java?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s