Java Tutorial


OOPS concept


Collection

Java - Datatypes

Data types specify size and the type of values that can be stored in an identifier.

Datatypes are classified in two categories:

  • Primitive data types
  • Non-Primitive data types

Primitive data types

In java, there are 8 types of primitive data types. These datatypes are predefined and are grouped into four different categories.

Integer

These group consists of four datatypes: byte, short, int, long.


Floating-Point Number

These group consists of two datatypes: float, double


Characters

These group consists of one datatype: char


Boolean

These group consists of one datatype: boolean

About datatypes

Data typeDefault ValueDefault Size (in byte)
booleanfalse1
char'\u0000'2
byte01
int02
short04
long0L8
float0.0f4
double0.0d8

Range of Datatypes

Data typeMin ValueMax Value
char'\u0000' (or 0)'\uffff' (or 65,535)
byte-128127
short-32,76832,767
int-2,147,483,6482,147,483,647
long -9,223,372,036,854,775,808 9,223,372,036,854,775,807
float1.40129846432481707e-453.40282346638528860e+38
double4.94065645841246544e-324d1.79769313486231570e+308d

Non-primitive (Reference) data types

They don't store value, but store a reference to that value. Reference types can be a class, interface, or array variable.


You will learn more in later sections in detail.

Advertisment

Share


Advertisement