Type a static factory method pair
Type a static factory method pair
Answer
public static Temperature ofCelsius(double c) { return new Temperature(c); }
The private constructor is hidden; callers use the named factory. The name makes the unit explicit — no guessing whether the double argument is Celsius or Fahrenheit.