Nice step-by-step @kfrajer. However, we can exceptionally have static
fields inside inner classes as long as they’re final
& either primitive or String; b/c in this case, they become compile-time constants:
void setup() {
final AutoCar car = new AutoCar();
println("Planet:", car); // Planet: MARS
exit();
}
class AutoCar {
static final String PLANET = "MARS"; // Compile-time constant
@Override String toString() {
return PLANET;
}
}