A friend was having a problem comparing two arrays in VB, so using the limited knowledge of Java that I had, I wrote this class to do the sorting for him. Basically, it is given two arrays. Both arrays will have a number of strings. Then it needs to check to see if any of the elements in the first array are contained in the second array. If so, they are to be deleted from the second array and the second array is finally returned. Because of the methods that a Vector provides, I thought that it would be easier to use a vector for this purpose. However, I didn't want to give him code that might not work. When I tested it, it seemed to work fine, but if anyone might see a possible error in the future or something I might not have considered, I'd appreciate any comments. Here's my code.
(edited by Cindy to format code) [This message has been edited by Cindy Glass (edited November 27, 2001).]
There's a very good tutorial on Collections on the Sun web site which covers 1. listing duplicates in 2 sets 2. removing duplicates in 2 sets amongst many other things. You should be able to get your methods working with about 5 lines of code ! http://java.sun.com/docs/books/tutorial/index.html