Java Data Type Tutorial - Java Data Type Intro

Java provides some predefined data types, which are known as built-in data types.

Java also let us define our own data types, which are known as user-defined data types.

A data type that consists of an indivisible value, and is defined without the help of any other data types, is known as a primitive data type.

Java provides many built-in primitive data types, such as int, float, boolean, char, etc.

We can give a name to a value of the int data type as

int i;


An identifier in Java is a sequence of characters of unlimited length.

The sequence of characters includes all Java letters and Java digits, the first of which must be a Java letter.

Java uses the Unicode character set. A Java letter is a letter from any language that is represented by Unicode character set. For example, A-Z, a-z, _ (underscore), and $ are considered Java letters from the ASCII character set range of Unicode.

Java digits include 0-9 ASCII digits and any Unicode character that denotes a digit in a language.

Spaces are not allowed in an identifier.

An identifier is the name given to a class, method, variable, etc. in a Java program.

There are three important things to remember about identifiers in Java:

  • There is no limit on the number of characters used in an identifier.
  • Characters used in an identifier are drawn from the Unicode character set, not only from the ASCII character set.
  • Identifiers are case sensitive.


Java defines a list of words called keywords.

Keywords are words that have predefined meanings in Java and they can only be used in the contexts defined by the Java language.

Keywords in Java cannot be used as identifiers.

The complete list of Java keywords is listed in as follows.

abstract            assert           boolean          break
byte                case             catch            char
class               const            continue         default
do                  double           else             enum
extends             final            finally          float
for                 goto             if               implements
import              instanceof       int              interface
long                native           new              package
private             protected        public           return
short               static           strictfp         super
switch              synchronized     this             throw
throws              transient        try              void
volatile            while

The two keywords, const and goto, are not currently used in Java.

They are reserved keywords and they cannot be used as identifiers.

In addition to all the keywords, three words, true, false, and null, cannot be used as identifiers; true and false are boolean literals (or boolean constants) and null is a reference literal.