Primitive Data Types in Java (With Examples)
In Java, primitive data types are the most basic building blocks of data. They store simple values directly in memory and are not objects. Java provides 8 primitive data types, categorized into: Nu...

Source: DEV Community
In Java, primitive data types are the most basic building blocks of data. They store simple values directly in memory and are not objects. Java provides 8 primitive data types, categorized into: Numeric Types Character Type Boolean Type Let’s explore each one separately 1. byte The byte data type is used to store small integer values. It saves memory in large arrays. Size: 1 byte (8 bits) Range: -128 to 127 Example: public class ByteExample { public static void main(String[] args) { byte age = 25; System.out.println("Age: " + age); } } 2. short The short data type is larger than byte but smaller than int. Size: 2 bytes Range: -32,768 to 32,767 Example: public class ShortExample { public static void main(String[] args) { short temperature = 15000; System.out.println("Temperature: " + temperature); } } 3. int The int data type is the most commonly used type for storing integers. Size: 4 bytes Range: -2,147,483,648 to 2,147,483,647 Example: public class IntExample { public static void mai