Java has eight primitive data types, which are the foundational building blocks for storing simple values directly in memory. These types are predefined by the language and do not require object instantiation.

The Eight Primitive Data Types in Java

  • boolean: Stores true or false values. Used for logical conditions.

  • char: Stores a single 16-bit Unicode character (e.g., 'A', 'z', '1'). Range: 0 to 65,535.

  • byte: An 8-bit signed integer. Range: -128 to 127.

  • short: A 16-bit signed integer. Range: -32,768 to 32,767.

  • int: A 32-bit signed integer. Range: -2,147,483,648 to 2,147,483,647. Most commonly used for integers.

  • long: A 64-bit signed integer. Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Use suffix L (e.g., 100L).

  • float: A 32-bit single-precision floating-point number. Use suffix f (e.g., 3.14f). Suitable for less precise decimal calculations.

  • double: A 64-bit double-precision floating-point number. Default for decimal values (e.g., 3.14159). More accurate than float.

Key Characteristics

  • Fixed size and range: Each type has a defined memory size and value limits.

  • Direct storage: Values are stored directly in the stack, making them fast and memory-efficient.

  • No null values: Primitive types cannot be null, reducing NullPointerException risks.

  • No methods: Unlike objects, primitives do not have methods; they only hold values.

  • Used for basic operations: Ideal for numbers, characters, and boolean logic in programs.

💡 Note: For collections (like ArrayList) or when null is needed, wrapper classes (e.g., Integer, Double, Boolean) are used to wrap primitives.

A primitive data type is just one of the basic data types that come with Java. I think they're int, byte, float, double, boolean, char, and long (String doesn't count). It becomes more relevant when you're declaring user-created data types as well. If I have a class called Square, I would do Square s = new Square(); or whatever to make a Square object. It's the same thing with primitives, it's just that any Java program you run has all the primitives loaded up for you. Answer from corpuscle634 on reddit.com
🌐
W3Schools
w3schools.com › java › java_data_types.asp
Java Data Types
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... int myNum = 5; // Integer (whole number) float myFloatNum = 5.99f; // Floating point number char myLetter = 'D'; // Character boolean myBool = true; // Boolean String myText = "Hello"; // String ... Non-primitive data types - such as String, Arrays and Classes (you will learn more about these in a later chapter)
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
Primitive values do not share state with other primitive values. The eight primitive data types supported by the Java programming language are: byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).
Discussions

ELI5: What is a primitive data type in Java?
A primitive data type is just one of the basic data types that come with Java. I think they're int, byte, float, double, boolean, char, and long (String doesn't count). It becomes more relevant when you're declaring user-created data types as well. If I have a class called Square, I would do Square s = new Square(); or whatever to make a Square object. It's the same thing with primitives, it's just that any Java program you run has all the primitives loaded up for you. More on reddit.com
🌐 r/explainlikeimfive
4
1
March 30, 2014
What are Java's primitive types? - Stack Overflow
Data type which holds values only are called primitive data types(byte,short,int etc.). And the other data types which contains references are called as reference data type (Integer,Boolean,String etc...). ... Save this answer. Show activity on this post. In Java, every variable has a type ... More on stackoverflow.com
🌐 stackoverflow.com
[Java] Newbie - Object and primitive data type
Not quite. In Java, there are only two data types: primitives and objects. The only primitive data types in Java are: byte, short, int, long, float, double, boolean, and char. Primitive types are essential basic building blocks built-in to the language. When you store a value into a primitive type variable, you are storing that value directly to memory. Object types, on the other hand, can be user-defined. Objects usually are composed of many properties, which can be primitives or objects. Objects can also have methods defined on them, whereas primitives cannot. When you instantiate a new object, the value of a variable will contain a reference to that object. So, primitives: int a = 5; // the value of a is actually 4 char myChar = 'c'; // the value of myChar is actually 'c' double d = 1.847; // the value of d is actually 1.847 Objects: String myString = "Hello"; // the value of myString is a reference MyClass aClass = new MyClass(); // the value of aClass is a reference Strings are objects because they are essentially a collection of characters. You can call methods on strings as well. More on reddit.com
🌐 r/learnprogramming
3
0
July 21, 2016
How important are primitive data types? More specifically in java.
You mean understanding char, int etc? Yes that's extremely important and fundamental to everything else in programming. More on reddit.com
🌐 r/learnprogramming
6
1
June 29, 2018
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-data-types
Java Data Types - GeeksforGeeks
Data types in Java define the kind of data a variable can hold and the memory required to store it. They are broadly divided into two categories: Primitive Data Types: Store simple values directly in memory.
Published   January 16, 2026
🌐
Wikibooks
en.wikibooks.org › wiki › Java_Programming › Primitive_Types
Primitive Types - Wikibooks, open books for an open world
January 28, 2006 - Primitive types are the most basic data types available within the Java language. There are 8: boolean, byte, char, short, int, long, float and double. These types serve as the building blocks of data manipulation in Java. Such types serve only one purpose — containing pure, simple values ...
🌐
Masai School
masaischool.com › blog › java-data-types
Exploring Java Data Types: Primitive and Reference Types
October 11, 2023 - Primitive data types directly house simple values, providing the building blocks for Java's data-handling capabilities. Whether you're dealing with numbers, characters, or logical conditions, these types are the bedrock of basic value representation ...
🌐
Baeldung
baeldung.com › home › java › core java › introduction to java primitives
Introduction to Java Primitives | Baeldung
January 8, 2024 - The simplest primitive data type is boolean. It can contain only two values: true or false. It stores its value in a single bit. However, for convenience, Java pads the value and stores it in a single byte.
Find elsewhere
Top answer
1 of 14
55

In Java, every variable has a type declared in the source code. There are two kinds of types: reference types and primitive types. Reference types are references to objects. Primitive types directly contain values. There are 8 primitive types:

  • byte
  • short
  • int
  • long
  • char
  • float
  • double
  • boolean
2 of 14
8

What do people mean by "Types"?

In the real world there are different "types" of things. e.g. There are many different "types" of vehicles: "sports cars" for driving fast, "utes" for carrying tools, "trucks" for transporting lots of goods, and limousines for traveling in luxury.

In the same way, in Java, you can have different "types" of data which serve different purposes: e.g. numbers (are used to add/subtract etc), "strings" are used to communicate words and letters. You cannot use letters to add - that just does not make sense, nor could you use numbers to write a sentence.

Primitives vs reference types - what does it mean? What's the difference?

Now there are some "types" of data which are basic. These are already created by the boffins at Redmond/Sun. These are called "primitive" java types, and they store the values within themselves. What does that mean? It's best explained by example:

Example of a primitive type

If I gave you a $50 note, then the note in and of itself is worth $50. The value is stored in the note itself.

Primitives Juxtaposed with Reference Types

Imagine that instead of giving you $50 I gave you an piece of paper which has on it an address to a safe deposit box. The piece of paper i gave you is not worth $50 in and of itself, but it points to an address where you can get your $50. This piece of paper is basically a "reference" type, because it doesn't store any values within and in and of itself, it merely points to certain addresses.

But I can give you an address to anything: planes, castles, rainforrests: anything!

Summary

You can't just hand someone a plane or a Shinkansen train from your back pocket: you just hand them an address to it. Juxtapose this with having $50, or any type of currency: the actual substance is in your back pocket.

That in an nutshell is the difference between primitive and reference types.

(Corny analogy used to help you understand and remember.)

🌐
Women Code Heroes
womencodeheroes.com › home › cooking with code: primitive data types in apex and java
Cooking with Code: Primitive Data Types in Apex and Java — Women Code Heroes
September 2, 2020 - Primitive data types can’t be broken down into smaller data types (e.g., Strings) Non-primitive data types can be broken down further (e.g., Lists contain elements ) Java and Apex have very similar primitive data types
🌐
Reddit
reddit.com › r/learnprogramming › [java] newbie - object and primitive data type
r/learnprogramming on Reddit: [Java] Newbie - Object and primitive data type
July 21, 2016 -

I've been reading the differences between the two but I'm having trouble visualizing them.

From what I've read:

Primitive - a value that cannot be broken anymore;

for example:

int variable = 8;

Object data - a value that is referenced/can be broken down

for example:

int var1 = 2;

var2 = var1;

Am I correct?

Also I've heard that integers are primitive data types, while Strings are object data types, why is that?

Top answer
1 of 3
4
Not quite. In Java, there are only two data types: primitives and objects. The only primitive data types in Java are: byte, short, int, long, float, double, boolean, and char. Primitive types are essential basic building blocks built-in to the language. When you store a value into a primitive type variable, you are storing that value directly to memory. Object types, on the other hand, can be user-defined. Objects usually are composed of many properties, which can be primitives or objects. Objects can also have methods defined on them, whereas primitives cannot. When you instantiate a new object, the value of a variable will contain a reference to that object. So, primitives: int a = 5; // the value of a is actually 4 char myChar = 'c'; // the value of myChar is actually 'c' double d = 1.847; // the value of d is actually 1.847 Objects: String myString = "Hello"; // the value of myString is a reference MyClass aClass = new MyClass(); // the value of aClass is a reference Strings are objects because they are essentially a collection of characters. You can call methods on strings as well.
2 of 3
1
Java has 8 primitive types: byte, short, int, long, float, double, char, boolean. The first 4 are integer types (each of which uses a different number of bytes). float and double represent floating point numbers. char is used for characters (although it too is just a number). boolean is either true or false. Everything that's not one of these 8 primitive types are objects, and inherit from the Object superclass. Strings are objects because they are not one of the 8 primitive types. Most things in Java (and other object-oriented languages) are objects. However, Java allows Strings to have and use special syntax, which is why working with strings don't always look the same as working with other objects. For instance, you can write String str = "hello"; and that makes a string even though you never used the new keyword. Perhaps the most important thing about primitives vs objects is that when you have a variable for some object (e.g. Person myPerson), the variable is a reference to an object (and is not the object itself).
🌐
Tutorialspoint
tutorialspoint.com › home › java › java basic data types
Java Basic Data Types
September 1, 2008 - This data type is primarily used to store individual characters. ... Following examples shows the usage of the various primitive data types we've discussed above. We've used add operations on numeric data types, whereas boolean and char variables are printed as such. public class JavaTester { public static void main(String args[]) { byte byteValue1 = 2; byte byteValue2 = 4; byte byteResult = (byte)(byteValue1 + byteValue2); System.out.println("Byte: " + byteResult); short shortValue1 = 2; short shortValue2 = 4; short shortResult = (short)(shortValue1 + shortValue2); System.out.println("Short:
🌐
Medium
medium.com › @AlexanderObregon › java-data-types-primitive-vs-non-primitive-417925cee746
Java Data Types: Primitive & Non-Primitive | Medium
November 16, 2023 - While efficient, primitive data types are not objects and therefore lack the capabilities of objects. They cannot call methods, and they don’t have fields. They are not part of the object hierarchy and cannot be used where objects are required, such as in generic types, collections, or class-based data structures. Here’s how you might declare and use these types in a Java program:
🌐
Codementor
codementor.io › community › primitive data types in java: understand the core essentials
Primitive Data Types In Java: Understand The Core Essentials | Codementor
March 22, 2024 - Java has 4 primitive types for holding integers: byte, short, int, and long. These types differ in the size of the data they can contain.
🌐
Oxford University
mathcenter.oxford.emory.edu › site › cs170 › variables
Variables and the 8 Primitive Data Types
The amount of memory allocated ... its type. There are 8 primitive types of data built into the Java language. These include: int, byte, short, long, float, double, boolean, and char....
🌐
ScholarHat
scholarhat.com › home
Data Types in Java : Primitive & Non-Primitive Data Types
Primitive data types in Java, like int, char, and boolean, store simple values directly. On the other hand, Non-primitive data types in Java, such as arrays, classes, and interfaces, are derived from objects.
Published   August 30, 2025
🌐
HWS Math
math.hws.edu › javanotes › c2 › s2.html
Javanotes 9, Section 2.2 -- Variables and the Primitive Types
A variable in Java is designed to hold only one particular type of data; it can legally hold that type of data and no other. The compiler will consider it to be a syntax error if you try to violate this rule by assigning a value of the wrong type to a variable. We say that Java is a strongly typed language because it enforces this rule. There are eight so-called primitive ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › primitive-data-type-vs-object-data-type-in-java-with-examples
Primitive data type vs. Object data type in Java with Examples - GeeksforGeeks
July 12, 2025 - They specify the size and type of any standard values. Java has 8 primitive data types namely byte, short, int, long, float, double, char and boolean. When a primitive data type is stored, it is the stack that the values will be assigned.
🌐
DataCamp
datacamp.com › doc › java › java-data-types
Java Data Types
Primitive data types are the most basic data types available in Java.
🌐
TheServerSide
theserverside.com › tutorial › Why-the-8-Java-primitive-data-types-are-not-objects
Why the 8 Java primitive data types are not objects | TheServerSide
January 30, 2020 - One of the tautological rules of Java programming is that everything in Java is an object except the things that aren't Java objects. The language defines eight Java primitive data types: boolean, float, double, byte, short, int, long and char.