I came across this answer while looking for a way to implement aggregation and composition in Java. Here's the answerer's implementation for composition -
final class Car {
private final Engine engine;
Car(EngineSpecs specs) {
engine = new Engine(specs);
}
void move() {
engine.work();
}
}
I wanted to ask whether it is mandatory to declare engine as private final for it to be a valid composition? Does composition also imply that the attributes of engine will never change during its lifetime?