Objective
A big difference between Java and C + + is the definition of an object. In C + +, defining an object is directly:
Class Name Object name (construction parameter);
You can do it.
But Java is not so defined. So how do you define it in Java? What are the implications of such a definition? This is what this article is going to tell you.
Methods for defining object variables in Java
Class Name Object name = new class name (structural parameter);
The smart reader must have discovered that the problem here- new Returns a pointer , and the assignment number to the left is a class type , is there an implicit conversion?
The answer is no.
The name of the class name Object in Java; An object variable is generated, which is itself a pointer type (pointing to an object), which differs from C + +. an object is generated directly in C + +.
It can be thought that the " object " in Java is actually a pointer to an object in C + +, which should be referred to as an object variable .
Object and object variables do not confuse