Thursday, April 26, 2012

Convert Arrays to Set in Java

Here is a example which demonstrates conversion of Array to Set in Java

Example: Java Array to Set





String [] countires = {"India", "Switzerland", "Italy"};
Set<String> set = new HashSet<String>(Arrays.asList(countires));
System.out.println(set);
 Output:
[Italy, Switzerland, India]

No comments:

Post a Comment