Kamran Iqbal
what's the difference between #static void method and void method?
By Kamran Iqbal in C# on Jul 15 2016
  • Mukesh Kumar
    Aug, 2017 31

    If we use static void then it executes before main Otherwise after main

    • 0
  • sushil kumar
    Jul, 2017 20

    static void method is a static method which does not return any thing. Static method can be called by directly by class name. void method is a method which also return nothing. But for calling simple method you have to create a class object and called method by object.method name.

    • 0
  • Ravi Kumar
    May, 2017 30

    1.> static void method is a static method that does not return anything. Static methods do not belong to any instance. They can only be called from the class directly. Eg. :public class MyClass{public static void myMethod(){System.out.println("My method");}}public class MyAnotherClass{public void callMyMethod(){MyClass.myMethod();}}The main method in a class is an example of a static void method. So the JVM process does not have to instantiate the class that contains the main method, to call the main method.2.> While, void methods are instance methods inside a class that do not return anything. Unlike static methods, instance methods belong to instances of the class and not to the class directly. Eg. :public class MyClass{public static void myMethod(){System.out.println("My method");}}public class MyAnotherClass{public void callMyMethod(){MyClass myClassInstance = new MyClass();myClassInstance.myMethod();}}

    • 0
  • Ravi Kumar
    May, 2017 30

    1.> static void method is a static method that does not return anything. Static methods do not belong to any instance. They can only be called from the class directly. Eg. :public class MyClass{public static void myMethod(){System.out.println("My method");}}public class MyAnotherClass{public void callMyMethod(){MyClass.myMethod();}}The main method in a class is an example of a static void method. So the JVM process does not have to instantiate the class that contains the main method, to call the main method.2.> While, void methods are instance methods inside a class that do not return anything. Unlike static methods, instance methods belong to instances of the class and not to the class directly. Eg. :public class MyClass{public static void myMethod(){System.out.println("My method");}}public class MyAnotherClass{public void callMyMethod(){MyClass myClassInstance = new MyClass();myClassInstance.myMethod();}}

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS