Java Data Types


Data types is a data storage which declaring variables of different types such as integer, floating, character and etc.

Data types is a data storage format that can contain a specific type or range of values. The kind of data that variables may hold in a programming language is called as data types.

Based on the data type the OS allocates the memory and decides what can store in the reserved memory.

Java Datatypes

In Java language two types of data types:

  • Primitive Data Types

    - int, char, float, double, boolean, long, and etc
  • Non-primitive / Object Data Types

    - Programmer created Data Types.

1. Primitive Data Types:

Integer:

It is used to represent integers in Java. Int data type range should be include -32767 to 32767.

int variable_name; 

Character:

It represents an individual character value i.e. a letter, a digit, or a specific symbol. Each type char value is enclosed in single quotes.

 char variable_name;

Floating Point:

In this numbers are stored in 32 bits, with 6 digits of precision.

float variable_name;

Double Floating Point:

This type of data type is used to represent real numbers. It uses 64 bits with 14 digits precision.

 double variable_name;

Data Types Storage size Range value
char 2 byte 0 to 65,535
int 4 byte -2,147,483,648 to 2,147,483,647
short 2 byte −32,768 to 32,767
long 8 byte -2^63 to 2^63 -1
float 4 byte 1.2E-38 to 3.4E+38
double 8 byte 2.3E-308 to 1.7E+308
boolean 1 bit true and false



Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.