您需要做的是
MutableObject return_immutable_field() { return immutable_field; }
改成:
MutableObject return_immutable_field() { MutableObject tmp = new MutableObject(); tmp.mutable_field = immutable_field.mutable_field; return tmp; }
有关说明,请参见http://www.javapractices.com/topic/TopicAction.do?Id=15
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)