Set<Integer> targetSet = new HashSet<Integer>(Arrays.asList(sourceArray)); // with google guava Set<Integer> targetSet = Sets.newHashSet(sourceArray);