Note that in Java, array indexes are 0 based, i.e. in the above array as it is now, c[0] is left empty, and the reference to c[10] causes an ArrayIndexOutOfBoundsException. Indexes should be 0..9 instead.
–
Péter TörökJun 12 '10 at 13:25

This is a nice, clever way to do this without any looping (in your code). The addAll() method, of course, will do all of that for you, and probably more efficiently since it can work with the internal implementation of the HashSet.
–
Craig TraderJun 13 '10 at 3:30

Here's a quick hack to do what you wanted to (hopefully also compiles):

// Assuming the code in the question is here.
java.util.List<cat> tmp = new java.util.LinkedList<cat>();
java.util.HashSet<String> set = new HashSet<String>();
for (int i = 0; i < c.length; ++i)
if (set.put(c[i].data)) tmp.add(c[i]);
c = tmp.toArray(c);