如何在Java中删除列表中的数组?

如何在Java中删除列表中的数组?,java,arrays,arraylist,Java,Arrays,Arraylist,我想删除列表Removelist1中的数组Removelist。如果Removelist数组只有一个值,则它可以正常工作,否则它将不会删除该数组。代码如下所示: for(int j=0;j<Removelist.length;j++) { System.out.println(Removelist[j]); if(Removelist1.contains(Removelist[j])) { System.out.println("Exists: "+Removelist[

我想删除列表Removelist1中的数组Removelist。如果Removelist数组只有一个值,则它可以正常工作,否则它将不会删除该数组。代码如下所示:

for(int j=0;j<Removelist.length;j++)
{

    System.out.println(Removelist[j]);
if(Removelist1.contains(Removelist[j]))
{
    System.out.println("Exists: "+Removelist[j]);
    Removelist1.remove(Removelist1.indexOf(Removelist[j]));
}
}
for(int j=0;j请尝试下一步:

String [] remove = {"a","b"};
List<String> data = new ArrayList<>();
data.add("a");
data.add("s");
data.add("b");
data.removeAll(Arrays.asList(remove));
System.out.println(data);
String[]remove={“a”,“b”};
列表数据=新的ArrayList();
数据。添加(“a”);
数据。添加(“s”);
数据。添加(“b”);
data.removeAll(Arrays.asList(remove));
系统输出打印项次(数据);
remove
是需要从
列表中删除的数组

数据
您的
列表

输出:
[s]

您无需迭代集合
removeAll()
method的每个元素。只需将数组强制转换为
collection
,如next:
Arrays.asList(remove)

要修复代码,您需要将
Removelist1.remove(Removelist1.indexOf(Removelist[j]);
更改为
Removelist1.remove(Removelist[j]);
请尝试下一步:

String [] remove = {"a","b"};
List<String> data = new ArrayList<>();
data.add("a");
data.add("s");
data.add("b");
data.removeAll(Arrays.asList(remove));
System.out.println(data);
String[]remove={“a”,“b”};
列表数据=新的ArrayList();
数据。添加(“a”);
数据。添加(“s”);
数据。添加(“b”);
data.removeAll(Arrays.asList(remove));
系统输出打印项次(数据);
remove
是需要从
列表中删除的数组

数据
您的
列表

输出:
[s]

您无需迭代集合
removeAll()
method的每个元素。只需将数组强制转换为
collection
,如next:
Arrays.asList(remove)

要修复代码,您需要将
Removelist1.remove(Removelist1.indexOf(Removelist[j]);
更改为
Removelist1.remove(Removelist[j]);
请尝试下一步:

String [] remove = {"a","b"};
List<String> data = new ArrayList<>();
data.add("a");
data.add("s");
data.add("b");
data.removeAll(Arrays.asList(remove));
System.out.println(data);
String[]remove={“a”,“b”};
列表数据=新的ArrayList();
数据。添加(“a”);
数据。添加(“s”);
数据。添加(“b”);
data.removeAll(Arrays.asList(remove));
系统输出打印项次(数据);
remove
是需要从
列表中删除的数组

数据
您的
列表

输出:
[s]

您无需迭代集合
removeAll()
method的每个元素。只需将数组强制转换为
collection
,如next:
Arrays.asList(remove)

要修复代码,您需要将
Removelist1.remove(Removelist1.indexOf(Removelist[j]);
更改为
Removelist1.remove(Removelist[j]);
请尝试下一步:

String [] remove = {"a","b"};
List<String> data = new ArrayList<>();
data.add("a");
data.add("s");
data.add("b");
data.removeAll(Arrays.asList(remove));
System.out.println(data);
String[]remove={“a”,“b”};
列表数据=新的ArrayList();
数据。添加(“a”);
数据。添加(“s”);
数据。添加(“b”);
data.removeAll(Arrays.asList(remove));
系统输出打印项次(数据);
remove
是需要从
列表中删除的数组

数据
您的
列表

输出:
[s]

您无需迭代集合
removeAll()
method的每个元素。只需将数组强制转换为
collection
,如next:
Arrays.asList(remove)

要修复代码,您需要将
Removelist1.remove(Removelist1.indexOf(Removelist[j]);
更改为
Removelist1.remove(Removelist[j]);
您不能使用

RemoveList1.removeAll(Arrays.asList(RemoveList));

你就不能用

RemoveList1.removeAll(Arrays.asList(RemoveList));

你就不能用

RemoveList1.removeAll(Arrays.asList(RemoveList));

你就不能用

RemoveList1.removeAll(Arrays.asList(RemoveList));

请发布更多代码…您有一个数组列表?您正在列表中搜索数组元素吗?removelist是什么?数组的数组是基本类型还是自定义对象?列表中有整个数组,还是只有元素?您能完成for循环的头吗?它丢失了。请尝试Removelist1.删除(removelist[j]);请发布更多代码…您有一个数组列表?您正在列表中搜索数组元素吗?removelist是什么数组?它是基本类型还是自定义对象?列表中有整个数组,还是只有元素?您能完成for循环的头吗?它丢失了。请尝试Removelist1.removelist(removelist[j]);请发布更多代码…您有一个数组列表?您正在列表中搜索数组元素吗?removelist是什么数组?它是基本类型还是自定义对象?列表中有整个数组,还是只有元素?您能完成for循环的头吗?它丢失了。请尝试Removelist1.removelist(removelist[j]);请发布更多代码…您有一个数组列表?您正在列表中搜索数组元素吗?removelist是什么数组?它是基本类型还是自定义对象?列表中有整个数组,还是只有元素?您能完成for循环的头吗?它丢失了。请尝试Removelist1.removelist(removelist[j]);它将有助于解释原始代码的错误。它将有助于解释原始代码的错误。它将有助于解释原始代码的错误。它将有助于解释原始代码的错误。