[Solved] Hello There! I am learning Java and completely unaware about it! what is diffrence between instance methods and non-static methods? [closed]


Instance method and non-static methods are same thing.

Different types of methods are :

  1. Instance methods: Which are associated with objects.
  2. Class methods: These are the static methods.

    class Demo{
        void hello(){
            System.out.println("Hello");
        }
        static void hi(){
            System.out.println("hi");
        }
    }
    

To call instance method you need to do,

new Demo().hello();

To call class method you can do,

Demo.hello();

In this class hello() is instance method. Every object of Demo class will have its own copy of hello() method.

Where as hi() method is class method and there will be only one copy of this method in the memory. All objects will call the same method.

16

solved Hello There! I am learning Java and completely unaware about it! what is diffrence between instance methods and non-static methods? [closed]