JAVA: First off, Thanks so much for taking the time to look at my question; your help is EXTREMELY appreciated!
So, the problem is i have a Vector of Objects in Java and each object has a name(String). But, i have tons of objects that are repeated, and the ones that are repeated are always directly after the Object they repeat. Also the number of repeats ranges from 1-10(So frustrating) its completely random.
How would i go about deleting the repeats, I thought about comparing each objects name with the next in the vector and deleting all of the ones that match but that gave me tons of problems. Thank you SO much for your help in advance!
-Dylan
EDIT: Just to make sure you understand the kind of repetition i’m talking about ive added this.
Edit 2: add Code
public class Vector
{
public static void main(String args[])
{
Person person1 = new Person("jane");
Person person2 = new Person("jane");
Person person3 = new Person("bob");
Person person4 = new Person("shelly");
Vector<Person> vectorObject = new Vector<Person>
vectorObject.add(person1);
vectorObject.add(person2);
vectorObject.add(person3);
vectorObject.add(person4);
}
}
class Person
{
String name = null;
String bDay = null;
String color = null;
public Person(String name)
{
this.name = name;
}
}
Well, I don’t know which language are you using, so I will give you an algorithm in JavaScript:
The problem is that this way a new vector is created, and if the original one is huge maybe you will have memory problems.