Need of Data Types

  • Data Types are used to store data temporarily in computer through a program
  • The data type will specify the type of data that will be stored into a memory location. 


  • The data type is something which gives information about
  • Size of the memory location and range of the data that can be accommodated inside that location.
  • Possible legal operations those can be performed on that location.
  • What type of result come out from an expression when we use these types inside that expression.
  • Whichever the keyword gives these semantics is treated as "data type".
  • The java language provides different categories of data types.

Different Java Data Types:

  • In java mainly we have two types of data types.
  1. Primitive data types or Fundamental data types.
  2. Referenced data types or Derived data types.

Data types in java

1.Primitives Data types:

  • The primitive data types are the predefined data types given by the programming language and they are meant for storing a single value.
  • Based on the type and range of data, primitive types are divided into 8 types.

1.Integer category: 

  • This category can be used for storing numbers which can be either positive value  or negative value without decimal points.
  • In this category we have 4 primitive data types whose memory sizes are different. 
  • All the 4 types under this category are used for storing same data. But there ranges are different. The java language is providing 4 types under Integer category. So that the memory is utilized efficiently. 
  1. byte  
  2. short
  3. int
  4. long
  •  Default value for all these types is "0".
Java Data types


2.Floating point category: 

  • This category can be used for storing numbers which can be either +VE or –VE with decimal point. In the floating point category we have two types whose size is different. The two data types are float and double.
  • Both the data types under the floating point category are used for storing same data but there range is different. The java language provide as two data types under floating point category so that memory is utilized efficiently. 
  • Default value of float is 0
  • Default value of double is 0.0 
  1. float
  2. double

Java Data types

3.Character category: 

  • This category can be used for storing a single character. A character can be represented by alphabets, a digit and special symbols. 
  • This category contains only one data type an it is char.
  • Default value of char is "one space"
  1. char
Java Data type

4.Boolean category: 

  • This category can be used for storing either true or false. Under the Boolean category only one data type an it is Boolean. The size is dependent on JVM to JVM.
Boolean data type

Limitations of primitive data types:

  • Using primitive data types we can not store multiple values in continuous memory locations
  • Due to this limitation we have to face 2 problems.


  • For instance if we want to store multiple values, for example 1 to 100 , we must create 100 variables. All those variables created across JVM at different locations as shown below.
  • Hence it takes more time to retrieve values.

Java data types memory allocation


  • Also using variables we can not pass all values to the remote computer with single network call, which increases burden on network and also increase lines of code in program.

Referenced data types:

  • To solve above two problems, values must be stored in continuous memory locations with single variable name .
  • This can be possible using referenced types.
  • Referenced types are given to store values in continuous memory locations with single variable name to retrieve data in quick time and to pass all values with single network call.
  1. Array
  2. Class
  3. Interface

Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
Newer Post
Older Post

No comments

Leave a Reply

Select Menu