Home >Java >javaTutorial >Ask the expert - New Operator
Why don't I need to use new for variables with primitive types, such as int or float?
Answer:
The primitive types of the Java language are not implemented as objects. Instead, due to efficiency concerns, they are implemented as “common” variables. A primitive type variable contains the value we give it.
As explained, object variables are references to the object. This layer of indirect addressing (and other features of objects) adds overhead to an object that is avoided by a primitive type.
The above is the detailed content of Ask the expert - New Operator. For more information, please follow other related articles on the PHP Chinese website!