You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Every program stores and manipulates data. Java is statically typed, which means every variable must be declared with a specific type before it can be used. This lesson covers primitive types, strings, type casting, and the var keyword.
int age = 25; // integer
double price = 19.99; // floating-point number
char grade = 'A'; // single character
boolean passed = true; // true or false
String name = "Alice"; // text (reference type)
A variable declaration has three parts:
type variableName = value;
| Convention | Example | Used For |
|---|---|---|
| camelCase | firstName, accountBalance | Variables and methods |
| PascalCase | BankAccount, StudentRecord | Classes and interfaces |
| UPPER_SNAKE_CASE | MAX_SIZE, PI | Constants (static final) |
Java has 8 primitive types built into the language:
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.