【发布时间】:2015-02-12 06:10:24
【问题描述】:
我创建了一个程序,用于存储关于 mp3 的三种不同信息。
我有一个trackNum、name 和 durationArrayLists。
我需要使用索引号从每个ArrayLists 中删除内容,这是我所做的:
//This is my method
public void removeTrack(Integer postion){
trackNum.remove(postion);
name.remove(postion);
duration.remove(postion);
}
//This is me using the method
case 2:
meth.print();
System.out.println("Please enter the index of the track you want to remove:");
meth.removeTrack(in.nextInt());
break;
我遇到的问题是它没有删除每个数组列表的索引,例如:
输入:
index trackNum name duration
0 111 1 1
1 2 2 2
2 3 3 3
3 4 4 4
如果我输入 2,则删除每个数组列表的索引 2。
输出:
index trackNum name duration
0 111 1 1
1 3 2 2
2 4 3 3
如果我输入 111 它将删除 111
那么有人可以帮我删除每个ArrayList 的索引内容吗?
【问题讨论】:
标签: java arrays methods arraylist