Primitive Data Types in Java

Primitive datatypes in Java are the most basic and fundamental types of data that represent simple values such as numbers, characters, or logical values. They are predefined by the language, not objects, and store values directly in memory.

Java provides 8 primitive datatypes, which cover different categories of values. These types are fast and memory-efficient because they work directly with the CPU and do not require object overhead.

  1. Integer Types → byte, short, int, long
  2. Floating-point Types → float, double
  3. Character Type → char
  4. Logical Type → boolean

Each primitive type has a fixed size, range, and default value, which makes Java a strongly typed language.

Primitive Data Types Table

Datatype Size Range Default Value Example
byte 1 byte -128 to 127 0 byte age = 25;
short 2 bytes -32,768 to 32,767 0 short temp = -200;
int 4 bytes -2,147,483,648 to 2,147,483,647 0 int salary = 50000;
long 8 bytes Very large (±9 quintillion) 0L long population = 7800000000L;
float 4 bytes ~6–7 decimal digits precision 0.0f float pi = 3.14f;
double 8 bytes ~15–16 decimal digits precision 0.0d double rate = 19.87654321;
char 2 bytes '\u0000' (0) to '\uffff' (65,535) '\u0000' char grade = 'A';
boolean 1 bit (JVM uses 1 byte internally) true or false false boolean isJavaFun = true;

Summary

Primitive datatypes are the simplest and most efficient way to store data in Java. Each datatype has a fixed size, range, default value, and storage format (base 2, IEEE-754, UTF-16, etc.), making Java a strongly typed and portable language.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar