Wednesday, 19 March 2014

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:
          If you find my answer interesting and easy to understand invite your friends to read this and Don’t Forget to Like and give your feedback and suggessions and FOLLOW me for More :)!!
Categories: , ,


Post a Comment

Subscribe to RSS Feed Follow me on Twitter!