源代码如下:不太明白加粗部分
class CowSubList extends AbstractList {
/*
* An immutable snapshot of a sub list's state. By gathering all three
* of the sub list's fields in an immutable object,
*/
private volatile Slice slice;
public CowSubList(Object[] expectedElements, int from, int to) {
this.slice = new Slice(expectedElements, from, to);
}
@Override public int size() {
Slice slice = this.slice;
return slice.to - slice.from;
}
。。。。。。
}