A class is a wrapper of a primitive variable, for example, the Integer class document states "The
Integer
class wraps a value of the primitive type
int
in an object. An object of type Integer
contains a single field whose type is int
."But there is still difference in usage, the class type variable can be assigned with value null and stored in the container while a primitive variable cannot. But primitive type is found to have advantage in performance, here is the discussion, Why do people still use primitive types in Java?
No comments:
Post a Comment