情况就是这个
class Immutable
{
public final int myField;
public Immutable(int value)
{
myField = value;
}
//methods that treat the object as immutable
}
class Mutable extends Immutable
{
//no longer final. The same field. Not subclass hiding superclass field.
public int myField;
//more methods, these mutate the state of the object
}
这可以用Java完成吗?甚至语言扩展?随着演员和所有。