Home >Java >javaTutorial >Ask the expert - New Operator

Ask the expert - New Operator

王林
王林Original
2024-07-31 10:30:41434browse

Pergunte ao especialista - Operador New

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:The finalize() methodNext article:The finalize() method