Loading lesson…
Level 1 · Apprentice0 XP
Replace a page of boilerplate with one line, and see why immutable data is safer.
Step 1 / 5
ProblemA simple value, a money amount, takes forty lines in classic Java: fields, constructor, getters, equals, hashCode, toString. Worse, the setters let any code change it after it was shared.
← → step
Before this: Classes, interfaces and polymorphism
🛠️ Your turn
Reading is not the skill, doing is. Try for ten minutes before you open the hint. Getting stuck first is what makes the solution stick.
1.Write a record Email(String value) that trims and lower-cases the value and rejects anything without an '@'. Show that two emails differing only by case are equal.