java - Arrays.asList() doubt? -


people aslist method convert array list , not copying, every change in 'alist' reflect 'a'. add new values in 'alist' illegal, since array have fixed size.

but, aslist() method returns arraylist<t>. how compiler differentiates line 3 5. line 3 gives me exception (unsupportedoperationexception).

        string[] = {"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 

this list implementation receive arrays.aslist special view on array - can't change it's size.

the return type of arrays.aslist() java.util.arrays.arraylist confused java.util.arraylist. arrays.arraylist shows array as list.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -