- byte
- short
- int
- long
- float
- double
- char
- boolean
Class types, Object types and Reference types all mean exact same; an object of a class. Examples : Object of a class Car, String, Integer,etc.
- Every variable irrespective of whether it is primitive or reference type is stored in the computer memory.
- For a primitive type of variable if you visit it's memory location you will find the value of the variable.
Now if you visit the location where x is stored you can find the value 3.
- For a reference type of variable if you visit it's memory location unlike the primitive type you will find a memory address pointing to other location and not the values of variables in Object. This memory address points to a location where the details of Object and values of variables inside it reside.
- Assignment - the primitive value is copied in primitive type where as in reference type the address is copied
- Comparisons - the primitive values are compared in primitive type where as in reference type the addresses are compared to check if they point to same object.
- Return - the primitive value is returned in primitive type where as in reference type the address is returned.
No comments:
Post a Comment