Here you can find the source of toHashSet(Object[] array)
public static HashSet toHashSet(Object[] array)
//package com.java2s; /*//ww w. ja v a2 s . co m * This file is part of the Jose Project * see http://jose-chess.sourceforge.net/ * (c) 2002-2006 Peter Sch?fer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ import java.util.*; public class Main { public static HashSet toHashSet(Object[] array) { HashSet result = new HashSet(); for (int i = array.length - 1; i >= 0; i--) result.add(array[i]); return result; } public static void add(Collection coll, Object[] array) { for (int i = 0; i < array.length; i++) coll.add(array[i]); } public static void add(Map map, Object[] array) { for (int i = 0; i < array.length; i += 2) map.put(array[i], array[i + 1]); } }