ArrayList
Javaでを使用するのは初めてです。いくつかのリストがあり、リストとその要素を削除するメソッドを作成したいと考えています。これが私がこれまでに持っているものです:
public void delete(double value){
list.remove(value);
}
その後、出力を取得したい:
public ArrayList<Double> getlist(){
return list;
}
リスト インターフェイスから:
指定されたコレクションに含まれるすべての要素をこのリストから削除します (オプションの操作)。
boolean removeAll(Collection<?> c);
So lets assume you have a few ArrayLists
like this...
ArrayList list1;
ArrayList list2;
ArrayList list3;
Are you saying that, depending on a given value, you want to remove one of these lists? So something like this...
public void deleteList(ArrayList listToRemove){
listToRemove = null;
}
public void chooseListToRemove(int listNumber){
if (listNumber == 1){
deleteList(list1);
}
else if (listNumber == 2){
deleteList(list2);
}
else if (listNumber == 3){
deleteList(list3);
}
}
Is this what you're trying to do?
Otherwise, are you saying you have a single ArrayList
that contains many other lists...
ArrayList allLists;
allLists.add(new ArrayList());
allLists.add(new ArrayList());
allLists.add(new ArrayList());
And you want to remove one of these lists like this...
public void deleteList(int listNumber){
allLists.remove(listNumber);
}
So that if you started with 3 lists in allLists
and then removed 1 of them, you could ask allLists.size()
and it would tell you that there are only 2 lists left?
If its neither of these, you'll really need to explain your question better so that we can help you.