public class Add {
public static void main(String[] args) throws Exception {
String s;
int i=0;
ArrayList<String> list = new ArrayList<>();
BufferedReader bf = new BufferedReader(new FileReader("C:\\Users\\86188\\IdeaProjects\\java\\SummerHoliday\\Jsu4\\src\\Jsu"));
while ((s = bf.readLine()) != null) {
list.add(s);
Object[] obj = {"删除", "下一个"};
int result = JOptionPane.showOptionDialog(null, s, "警告", JOptionPane.DEFAULT_OPTION, -1, null, obj, obj[0]);
if (result == 0) {
System.out.println("删除");
list.remove(i);
i++;
} else if (result == 1) {
System.out.println("下一个");
} else {
System.exit(0);
}
}
System.out.println(list);
}
}
困扰我一天的问题了,删不了集合的第二个索引,为什么!集合一共3个索引