← Learning Tracks

Java Backend

Learn Java fundamentals and grow toward APIs, persistence, and reliable backend services.

Lesson 1: Classes and objects

A class describes a kind of object. It can define fields for data and methods for behavior. An object is one instance of that class.

class Greeting {
private final String name;
Greeting(String name) { this.name = name; }
String message() { return "Hello, " + name + "!"; }
}
Greeting greeting = new Greeting("Ada");
System.out.println(greeting.message());

The constructor sets up each instance. The private field keeps internal data protected, while the method exposes a useful behavior.

Practice

Make a Book class with a title field and a method that returns a short description. Create two objects with different titles.