I have it:
import java.util.Arrays; import java.util.List; import java.util.ArrayList; public class ListTest { public static void main(String[] args) { String[] values = { "yes", "no"}; List<String> aa = Arrays.asList(values); System.out.println(aa.getClass().getName()); aa.remove(0); } }
He gives:
$ java ListTest java.util.Arrays$ArrayList Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.remove(AbstractList.java:161) at ListTest.main(ListTest.java:12)
Question: I understand why I get this exception. This is because the ArrayList class is used from within Arrays.java , which does not have a remove() method. My question is, how does someone (any user, like me), before using, what List got that it does not contain the remove method?
source share