*
The moose likes Beginning Java and the fly likes vector program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "vector program" Watch "vector program" New topic
Author

vector program

tyler jones
Ranch Hand

Joined: Dec 01, 2000
Posts: 101
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).]
Colin Kenworthy
Ranch Hand

Joined: Aug 06, 2001
Posts: 88
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: vector program
 
Similar Threads
ItemStateListener & Interaction between two choicegroups
labelled break
compare two string array pick odd ones
Passing Parameters between classes
Sorting the JTable