HashSet boog = new HashSet();
boog.add(new String[]{\"a\", \"b\", \"c\"});
boog.add(new String[]{\"a\", \"b\", \"c\"});
boog.add(new
The "better way" is to use collections. Use a List instead of a String[]:
Set> boog = //...
boog.add(Arrays.asList("a", "b", "c"));
boog.add(Arrays.asList("a", "b", "c"));
boog.add(Arrays.asList("a", "b", "d"));
System.out.println(boog.size()); // 2
If you absolutely needed to use arrays as keys, you could build a transparent wrapper around each key and put that in the map. Some libraries help you with that. For example, here's how you could do a Set using Trove:
Set boog = new TCustomHashSet(new ArrayHashingStrategy());
boog.add(new String[]{"a", "b", "c"});
boog.add(new String[]{"a", "b", "c"});
boog.add(new String[]{"a", "b", "d"});
System.out.println(boog.size()); // 2
//...
public class ArrayHashingStrategy extends HashingStrategy