Android[ ArrayList ]
程式碼:
int a =1;
int b =2;
int c =3;
ArrayList<Integer> list = new ArrayList();
list.add(a);
list.add(b);
list.add(c);
for(int i = 0 ; i < list.size(); i++ )
Log.d("ooxx","first LinkedList"+list.get(i));
for(int i = 0 ; i < list.size(); i++ )
{
if (list.get(i) == 2 ) {
list.remove(i);
list.add(2);
}
}
for(int i = 0 ; i < list.size(); i++ )
Log.d("ooxx","second LinkedList"+list.get(i));
結果:
沒有留言:
張貼留言