Translate the specification below into an idiomatic Java class definition.
(In this context, "idiomatic" means following the common style and conventions of the language.)
One kind of thing that exists in our model is a Danioul.
Each Danioul has its own cle, which is an int. The value of cle is specified when a Danioul is created. Anyone can ask a Danioul for the value of its cle. The value of cle for a specific Danioul can never change.
public class Danioul {
private int cle;
public Danioul(int cle) {
this.cle = cle;
}
public int getCle() {
return cle;
}
public void setCle(int cle) {
this.cle = cle;
}
}
Things to check in your solution:
public and private modifier correct?static?final?Acceptable variations in the solution:
+= 1 instead of ++.Related puzzles: