Composition

Building a class from other objects that handle parts of its work.

What is Composition in Java?

Composition — Building a class from other objects that handle parts of its work.

class Engine {
    String start() {
        return "Started";
    }
}

class Car {
    private final Engine engine = new Engine();

    String drive() {
        return engine.start();
    }
}

Level: Journeyman · More Java terms at this level

Updated

In other subjects