ODNYX.

Java Syntax and Variables

Video Tutorial Coming Soon — Channel Production Underway

Java is statically typed, which means every variable must have a declared type before you use it, and that type can’t change later.

Tip: getting comfortable with types early pays off — it's the single biggest mental shift if you're coming from a dynamically-typed language like Python or JavaScript.

Declaring variables

int age = 25;
double price = 19.99;
boolean isActive = true;
String name = "Odnyx";

Common primitive types you’ll use constantly:

  • int — whole numbers
  • double — decimal numbers
  • boolean — true or false
  • char — a single character
  • String — technically not a primitive, but you’ll use it just as often

Statements and blocks

Every statement ends with a semicolon ;, and code blocks are grouped with curly braces { }:

if (age >= 18) {
    System.out.println("Adult");
} else {
    System.out.println("Minor");
}

What’s next

Next section: we move from Foundations into Object-Oriented Programming, starting with classes and objects.

📋 Java Foundations Interview Questions