+ 1
Guys what's the difference between both the term..it's little bit confusing : Initialization and Instantiation?
6 Answers
+ 4
Initialization occurs when you assign something to a variable.
In the other hand, Instantiation is the process of making an object of a type (class).
Both are far different but can be used at the same time:
ClassName uwu = new ClassName();
Here, you assigned (initialized) the variable 'uwu' with a reference of the created (instantiated) object in the class 'ClassName'.
Ref: https://stackoverflow.com/questions/15074083/difference-between-initializing-a-class-and-instantiating-an-object
+ 1
Google it
+ 1
int i;
Class_Name obj;
i=0; //initialization, assinging value
obj=new Class_Name(); //instantiation. Creating new datatype or object
+ 1
Rajat Porwal Dude not every time google can solve your problem...sometime if you want to understand thing better , get it from the person who use that term frequently in it's program coz he is exprienced and can teach your better....If you don't wanna explain better don't reply.
Liking your own comment lmao
+ 1
SPICEAPPLE đ { active: 0 } Jayakrishna Thanks it cleared my confusion...
+ 1
Initialization- Assigning a value to a variable i.e a=0, setting the initial values.
Instantiation- Creating the object i.e when you are referencing a variable to an object with new operator.
Code:
int a;//Declaration
a=10;//Initialization
Integer int1=new Integer(5);//Instantiation where Integer is a class and int1 is reference variable