Posts Tagged ‘data types’


data types can be categorized into two category and so variable.

  • Primitive Type and
  • Reference Type

Primitive Type – Primitives are like the cups at the Coffee-House They come in different sizes and each has name like small , big, medium. Java primitives come in different sizes and name. You must declare a variable with a specific type.

Example

byte x=10; // Take 1 byte in memory

short y=500; // Take 2 bytes in memory

int a=40000; // Take 4 bytes in memory

data types

data types

 

Primitive Data Types List

In Java, primitives come in different sizes with different names. When you declare a variable in Java, you must declare with a specific type.

data type size list

java primitive

 

Reference type

A Reference variable holds bits that represents a way to access an object. It doesn’t hold the object itself, but it holds something like reference address to the object. Reference type does not have size or bit depth.

java reference type

reference type

 

_______________________________________________________________________________