Tuesday, 29 March 2016

How to convert array to collection and vice versa ?


Array to List
Integer[] numArr = {100, 200, 300, 400, 500};
List numList = Arrays.asList(numArr);


Set to Array
Set langSet = new HashSet();
langSet.add("C");
langSet.add("C++");
langSet.add("Java");
langSet.add("Perl");
langSet.add("Sql");

Object[] langArr = langSet.toArray();

No comments:

Post a Comment

Note: only a member of this blog may post a comment.