int count=0
Position a = sortedlist.get(count);
if(...)
{
System.out.println(sortedlist);
//change the arraylist index(count) here
sortedlist.set(count, new Position(a.start(),sortedlist.get(i).start(),a.height()));
System.out.println(sortedlist);
//print out position a, prospected changed value
System.out.println(a);
}
目录将显示
[<2.0, 5.0, 4.0>, <4.0, 7.0, 3.0>, <1.0, 3.0, 2.0>, <2.0, 4.0, 1.0>]
[<2.0, 4.0, 4.0>, <4.0, 7.0, 3.0>, <1.0, 3.0, 2.0>, <2.0, 4.0, 1.0>]
<2.0, 5.0, 4.0>
不知道为什么即使 index0 的 Arraylist 元素更改后, a 仍将保持原来的 index0 值。