Are you weak in programs, click this
Click the image to know more

Java Data Types


Data types are:

  • Primitive data types(total 8 types) – byteshortintlongfloatdoubleboolean,char
  • Non-primitive data types – array, class and interface

Primitive Data Types

A primitive data type specifies the size and type of variable values, and it has no additional methods.

There are eight primitive data types in Java.

Non-Primitive Data Types

Non-primitive data types are called reference types because they refer to objects.

The main difference between primitive and non-primitive data types are:

  • Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String).
  • Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.
  • A primitive type has always a value, while non-primitive types can be null.
  • A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter.
  • The size of a primitive type depends on the data type, while non-primitive types have all the same size.

Examples of non-primitive types are StringsArraysClasses, Interface, etc. You will learn more about these later.


my students

Learn java simple code