嗨 我已经写了这个代码,与输出,你可以得到.remove()
方法不起作用。 a
,b
,c
和d
是一些Points
对象有x
和y
成员。删除方法为arrayList不起作用
这里是a and b and c and d
值,它在if语句中必须删除upper
但它不是。
X :59 Y: 143
X :165 Y: 140
X :59 Y: 143
X :165 Y: 140
System.out.println(upper.toString());
for(int i =0;i<upper.size();i++)
if(upper.get(i)==a||upper.get(i)==b||upper.get(i)==c||upper.get(i)==d){
upper.remove(i);
}
for(int i =0;i<lower.size();i++)
if(lower.get(i)==a||lower.get(i)==b||lower.get(i)==c||lower.get(i)==d){
upper.remove(i);
}
System.out.println(upper.toString());
System.out.println(lower.toString());
first println : [X :108 Y: 89, X :165 Y: 140]
second println: [X :108 Y: 89, X :165 Y: 140]
third println : [X :105 Y: 191]
必须有一个容易/更好的方式做你想做的事 – 2010-11-21 14:00:19
我编辑了我的问题。 – user472221 2010-11-21 14:04:35
哇。我可以说吗?牙套。具体来说,卷曲的。真。或者你是否主动要求维护程序员在看到这些代码时跳过? ;-) – 2010-11-21 14:07:10