Home > Back-end >  Java small white to kneel for great god guidance!
Java small white to kneel for great god guidance!

Time:10-12



Want to ask that the two red box two sentences, what's different?

"New test04 (). A" new for creating a new object, that whether the code of new:
1. On behalf of the created an object of type int? But like a Java object is basic type in it?
2. Or is this code is in memory has opened up a space, to deposit an int variable, and then returns the address of the variable?

CodePudding user response:

New representatives to create an object that's right, but this object is not of type int, but test04 type,
Object is stored in a heap area, object reference points to the heap area the object memory address

CodePudding user response:

Nothing too big difference, print place just returned to the temporary variable, the address assignment is equivalent to the return of temporary variable assigned to b, c variable
New created test04 object first, and then call the object. A get a property of the object to the value of the attribute operator to c

  • Related