MyWhiteBoard TrainingHome

PRACTICAL JAVA COURSE

Java Programming from Foundations to Object-Oriented Design

Build Java programs with clear types, classes, collections, and error handling. Every topic includes a source example that opens directly in Open Editor.

What you will learn

  • Write and run Java programs using types, decisions, loops, and methods.
  • Model real data with classes, constructors, encapsulation, and inheritance.
  • Use arrays, strings, collections, files, generics, and exceptions.
  • Apply streams, lambdas, tests, and debugging habits in practical code.

Practice method: open each sample in Open Editor, run it, then change one value and predict the result before running again.

1. Core language basics

Program shape

Java programs run from a main method. Classes group related state and behavior.

class Main {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

Types and control flow

Use explicit types and braces around blocks. A for loop is ideal when the iteration range is known.

for (int number = 1; number <= 5; number++) {
    if (number % 2 == 0) {
        System.out.println(number);
    }
}

2. Objects and classes

Classes model meaningful state

Keep fields private and use methods to maintain valid object state.

class Counter {
    private int value;

    void increment() {
        value++;
    }

    int value() {
        return value;
    }
}

Inheritance should be intentional

Use inheritance for a genuine is-a relationship. Interfaces are useful for a shared capability.

interface Printable {
    void print();
}

3. Collections, files, and reliability

Use the Java Collections Framework for groups of data, try/catch for expected failures, and try-with-resources to close files automatically.

List<String> names = List.of("Ada", "Lin");
for (String name : names) {
    System.out.println(name);
}

Reliable Java: validate external input, catch specific exceptions, close resources automatically, and write tests for behavior that must not change.

Before you move on

  • I can write a Java class with main.
  • I can create and call methods.
  • I can use constructors and private fields.
  • I can select a collection for a data problem.
  • I can handle a known exception.
  • I can read a compiler error and fix it.