KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
People say that asList method convert the array into list and its not copying, so every change in 'aList' will reflect into 'a'. So add new values in 'aList' is illegal, since array have fixed size. But, asList() method returns ArrayList<T> . How the compiler differentiates line 3 from 5. Line 3 gives me exception ( UnsupportedOperationException ). String[] a = {"a","b","c","d"};//1 List<String> aList = Arrays.asList(a);//2 aList.add("e");//3 List<String> b = new ArrayList<String>();//4 b.add("a");//5
Tags (comma-separated)
Save Edits
Cancel