Lesson contents

24 core lessons

Java programming tutorials

Write your first Java class, practice control flow and collections, and use the library guides to work with text, files, dates, and exceptions.

Java core curriculum

Getting started

  1. Environment setup
  2. Hello World
  3. Programming fundamentals
  4. Variables
  5. Data types
  6. Final
  7. Operators

Decisions and loops

  1. If else statement
  2. Ternary operator
  3. Switch statement
  4. For loop
  5. While loop
  6. Do while loop
  7. Break statement
  8. Continue statement

Functions and data

  1. Static methods, parameters, and scope
  2. Counting values with List and Map
  3. Parsing strings with a split limit
  4. Modeling values with records
  5. Validating input with OptionalInt

Files and projects

  1. Reading files with try-with-resources
  2. Generic methods and predicates
  3. Organizing code across files
  4. Inventory project with boundary tests

Reverse the digits of a number

Java source
class ReverseNumber {
    public static void main(String[] args) {
        int input = 123;
        int temp, r, output = 0;
        temp = input;

        while (temp > 0) {
            r = temp % 10;
            temp = temp / 10;
            output = output * 10 + r;
        }

        System.out.println("Original Number : " + input);
        System.out.println("Reverse Number : " + output);
    }
}
Output
Original Number : 123
Reverse Number : 321