final Variables and Immutable Data
|
|
Create immutable data using blank final instance variables |
|
|
|
Use final class variables to store "well-known" immutable values |
|
|
You must allocate new instances for new immutable values |
|
|
Don't forget equals and hashCode
|
|
|
Java has many immutable types, including String,
the wrapper classes (Integer, etc.), and
File
|