Primitive vs Object types?


  • Primitive types are the most basic types that Java supports. They are predefined as reserved keywords by the language and use a small amount of memory to represent a unit of data. Some primitive types are int, long, byte, double etc.
  • The other Object types are types that have classes (which extend Object.class) and can be instantiated with the new keyword (if there's an appropriate constructor). The object types are usually complex types, a composition of properties and methods that take up a bigger chunk of the memory.
0 answers