Data Types in Java

In this article we will learn about Data Types in Java.

Data Types in Java

Data Type:

Simply, Data Type refers to the type of data that can be stored in a variable. But internally a data type tells the compiler or interpreter how the programmer is going to use that variable, which value the programmer is going to assign and finally which operations can be performed on those values.

More important an Operating System(OS) assigns memory and reserve that memory space for a particular type of value based on the data type of the variable.

As Java is statically typed language, so a variable in java must be declared with specified type before use.

There are 2 types of data types in Java.

  1. Primitive data type
  2. Non Primitive data type

datatype in java

Primitive Data Type:

Primitive data types are the most basic data types which are used for data manipulation and behaves as the building block of non-primitive data type.

Generally primitive data types hold a single value. When a program is executed, compiler recognizes these primitive datatypes as these are hard coded into it.

There are 8 types of primitive data types.

  1. byte
  2. short
  3. int
  4. long
  5. float
  6. double
  7. boolean
  8. char

Non-Primitive Data Type:

These non-primitive data types refers to objects. So it is also called as Reference data type which contains a memory address of variable values as it does not store the variable value directly in memory. These variables are not created by Java rather created by the programmers.

Some of the non-primitive data types are

  1. Classes
  2. Interfaces
  3. String
  4. Arrays etc.

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.