+ 1

What is The "new" keyword in Java? i am confused.

please help me as a friend, Thank You Very Much

26th Nov 2017, 9:41 AM
Coding Hero
Coding Hero - avatar
3 Respuestas
+ 4
The new operator instantiate a class by allocating memory for a new object and returning a reference to that memory. The new operator also invoke object constructor. The new operator returns a reference to the object it created. This reference assigned to the variable of the appropriate type like:          A ob = new A(); While using  new  keyword some points to be remember : The  new  keyword is followed by a class name and passing values to the constructors. Number of arguments to the constructors must be the same in signature of constructor. The type of variable on the left side of assignment  is compatible with the class being instantiated.
11th Dec 2017, 10:20 AM
Prabhat Thakur
Prabhat Thakur - avatar
+ 3
allocates a space in the memory and initialize the object.
26th Nov 2017, 9:46 AM
Roabs
Roabs - avatar
+ 1
thanks dude
26th Nov 2017, 9:46 AM
Coding Hero
Coding Hero - avatar