-1

I'm trying to remove words starting with &, but the followning code gives me the following error:

Exception in thread "main" java.lang.UnsupportedOperationException
at java.util.AbstractList.remove(AbstractList.java:161)
at java.util.AbstractList$Itr.remove(AbstractList.java:374)
at java.util.Collection.removeIf(Collection.java:415)
at com.APT.SearchEngine.Main.main(Main.java:25)

String text="Hey &i love football";
List<String> purifiedList= Arrays.asList(text.split(" "));
purifiedList.removeIf((String word) -> word.startsWith("&"));
Ahmed Khairy
  • 145
  • 2
  • 16

1 Answers1

0

Arrays.asList returns an unmodifiable list.

Joe Attardi
  • 4,381
  • 3
  • 39
  • 41