Java Keywords and Object Behaviour
This section covers the Java words and rules that decide how an object behaves: static (belongs to the class, not to one object), final (cannot be changed after it is set), how the values you hand to a method are passed, equals() and hashCode() (how two objects are compared, and how a number helps collections find them), immutability (an object that never changes after creation), records (short classes that only carry values) and enums (a fixed set of named choices). The details here are the rules of Java; other languages differ.
After this section you can explain each of these, predict the output of short code, and fix a broken equals.
Topics in this section
- static
- final
- Pass by value
- equals() and hashCode()
- Immutability
- Records and enums