我有一个带有值的数组列表
ArrayList<String> HexValues = new ArrayList<String>();
HexValues.add("a");
HexValues.add("b");
HexValues.add("f");
HexValues.add("1");
HexValues.add("4");
HexValues.add("0");
HexValues.add("31");
HexValues.add("32");
HexValues.add("37");
System.out.println("The content of HexValues is: " + HexValues);
int start = HexValues.lastIndexOf("f");
if (start != -1) {
List<String> HexValuesEnd = HexValues.subList(start, HexValues.size());
System.out.println("The content of HexValuesEnd before leaving is: " + HexValuesEnd);
if (HexValuesEnd.size() > 0) {
HexValuesEnd.remove(1);
HexValuesEnd.remove(2);
HexValuesEnd.remove(3);
System.out.println("The content of HexValuesEnd after removing values at indexes 1 ,2,3: " + HexValuesEnd);
}
}
输出是
The content of HexValues is: [a, b, f, 1, 4, 0, 31, 32, 37]
The content of HexValuesEnd before leaving is: [f, 1, 4, 0, 31, 32, 37]
The content of HexValuesEnd after removing values at indexes 1 ,2,3: [f, 4, 31, 37]
但第二个数组列表中的预期值应该是
"The content of HexValuesEnd after removing values at indexes 1 ,2,3: " [f,31,32,37]
我哪里错了才能得到预期的结果..