What is the exact meaning of instantiate in JAVA

后端 未结 7 1066
孤独总比滥情好
孤独总比滥情好 2021-01-01 03:37

I\'am a newbie in JAVA and this came across this word called. \"A class i.e. created inside a method is called local inner class in java. If you want to invoke the methods o

7条回答
  •  囚心锁ツ
    2021-01-01 04:26

    To instantiate a class means to create an instance of the class. In other words, if you have a class like this:

    public class Dog {
        public void bark() {
            System.out.println("woof");
        }
    }
    

    You would instantiate it like this:

    Dog myDog = new Dog();
    

    Instantiating is when you use the new keyword to actually create an object of your class.

提交回复
热议问题