Class declarations and object modeling: Correct Solution


Translate the specification below into an idiomatic Java class definition.

(In this context, "idiomatic" means following the common style and conventions of the language.)

  1. One kind of thing that exists in our model is a Chlem.

  2. All Chlems share a single THECRAP, which is a string. It is a constant. Its value is "ge". Other classes cannot see its value.

Solution

public class Chlem {
    public static String THECRAP = "ge";

    public Chlem() {
    }
}

Things to check in your solution:

Acceptable variations in the solution:


Related puzzles: