外部不可变和内部可变类的示例
class MyClass { private final int value; private int halfValue = Integer.MAX_VALUE; /*from 时代Java公众号*/ public MyClass(int value) { this.value = value; } public int getValue() { return value; } public int getHalfValue() { // Compute half value if it is not already computed if (this.halfValue == Integer.MAX_VALUE) {/** from nowjava.com - 时 代 Java**/ // Cache the half value for future use