Java Data Type:

  • Data types represent the different values to be stored in the variable. Any value store in Variable using Java Data type.
  • Using Java Data Types we can return value to perform any operation.
  • Data type is used for representing the data in main memory (RAM) of the computer.


In java, there are two types of data types

  1. Primitive Java data types.
  2. Non-primitive Java data types.


Primitive data types

  • byte, short, int and long data types are used for storing whole numbers.
  • float and double are used for fractional numbers.
  • char is used for storing characters(letters).
  • boolean data type is used for variables that holds either true or false.


Example of Primitive DataType:



Non-primitive data types

  • Non-primitive data types are created by programmer.
  • String, Array are Non-Primitive Datatypes.
  • It is also called as ‘Reference Variables’ or ‘Object reference’ because it refers a memory location where data is stored.
  • On the other hand, primitive data types stores value.



  • It is class in java provided with several methods used to store group of characters.
  • Example: abcd, india123 etc. String is not a primitive data type because it has methods and only class can have methods.
  • Primitive data types cannot have methods. So, String is a class which is non-primitive type.
  • ‘String’ is used to represent string class.




  • Object is an Instance of a class with states and behaviors.


characteristics of aobject:

state: represents statistics (value) of an object.
behavior: represents the behavior (functionality) of an object consisting of deposit, withdraw and many others.
identificationitem identification is normally applied through a unique identification. The price of the id is not visible to the outside personhoweverit’s miles used internally by using the JVM to become aware of every object uniquely.



  • Array is non-primitive data types because it refers to the memory location.
  • An array is a collection of like-typed variables which are referred to by a common name.