Convert ArrayList To Arrays In Java http://ift.tt/Nsck9J...

Please Visit: http://ift.tt/1ajReyV



Convert ArrayList To Arrays In Java

http://ift.tt/Nsck9J

String [] countries = list.toArray(new String[list.size()]);



Convert Array to ArrayList

tring[] countries = {"India", "Switzerland", "Italy", "France"};

List list = Arrays.asList(countries);

System.out.println("ArrayList of Countries:" + list);

The above code will work great. But list object is immutable. Thus you will not be able to add new values to it. In case you try to add new value to list, it will throw UnsupportedOperationException.



Steps to convert Java ArrayList to Array. java.util.ArrayList to Java Array







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/Nsck9K

via LifeLong Community

No comments:

Post a Comment