Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Core Java & Object-Oriented Architecture 14 mins read Free Lesson

Java Variables, Data Types & Operators

Master Java 8 primitive data types (byte, short, int, long, float, double, boolean, char) and reference types.

Java Primitive Data Types

Java is a strongly-typed language. Variables must be explicitly declared with their type:

int age = 28;
double salary = 85000.50;
boolean isActive = true;
char grade = 'A';
String name = "Alex Morgan"; // Reference Type

// Type Casting (Widening & Narrowing)
double converted = age; // Automatic widening (int to double)
int truncated = (int) salary; // Explicit narrowing (double to int)