Data types and Identifier in Java

Data Type

  • A data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. A string, for example, is a data type that is used to classify text and an integer is a data type used to classify whole numbers.
  • Depending on the datatype,the operating system allocate memory and decides what type of data to be stored EX-a number,a character

There are 2 type of datatype-

Primitive Data Type

Reference Data Type also know as Object Data Type or Non-Primitive

Primitive Data Type-

  • There are 8 primitive data type supported by java.
  • Primitive datatype are predefined by the language and named by a Keyword.
  • Let see the following datatype-
  • byte-8 bit,and integer type,default value is 0.
  • short-is integer type and takes 2  bytes,default value is 0.
  • int-is integer type and takes 4 bytes,default value is 0.
  • long-is integer type and takes 8 bytes,default value is 0L.
  • float-is decimal type value,single precision  and takes 4 bytes,default value is 0.0f
  • char-can store any character and takes 2 bytes,default value is 'u0000'.
  • double-is decimal type value,double precision and takes 8 bytes,default value is '0.0d'.
  • boolean-It takes one bytes and can store either of two values;True or False,default value is FALSE.
  • type of datatype

Primitive data type are those whose variable allows us to store only one value but they never allows us to store multiple value of same type.This is a datatype whose variable can hold maximum one value at a time

Non-Primitive Data type-They are basically defined as derived data types.They are directly or indirectly dependent on primitive data types.The method for storing non-primitive datatype is different from primitive data type.They store the values with reference to the addresses or locations.So,they are also called 'Reference Data type'.


  • Arrays
  • Interfaces


All java component require names.Name used for classes ,method,interface and variable also called identifier.

Identifier follow some rule's which are listed below-

  • All identifiers must start with either a letter(a to z or A to Z) or currency($)character or an underscore.
  • After the first character ,an identifier can have any combination of character.
  • A Java Keyword cannot be used as identifier.
  • Identifier in Java are case sensitive,foo FOO are two different identifier.