I have tried below code
String s[]={\"1\",\"2\",\"3\",\"4\"};
Collection c=Arrays.asList(s);
System.out.println(c.remove(\"1\") +\" remove flag\");
Syste
I was having this problem, because I was also initializing my list with Arrays.asList
:
List names = Arrays.asList("a", "b", "c");
To solve the problem, I used addAll
instead:
List names = new ArrayList();
names.addAll(Arrays.asList("a", "b", "c"));
This way you can edit the list, add new items or remove.