Deleted for privacy.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Deleted for privacy.
Last edited by shanklove; September 7th, 2010 at 04:57 PM.
Have you read about java.util.Set?, take a look then refactor your code.
Eduardo Yáñez Parareda
http://serfj.sourceforge.net - Simple Ever REST Framework for Java
http://serfj.wordpress.com
Ok, so what is wrong with this process:
1. Combine the two ArrayLists using ArrayList.addAll(Collection<? extends E> c)
2. Go through the new ArrayList and remove all duplicates. This can be done in two ways:
A) (Standard Way) Embedded For loops where the first For loop goes through the entire ArrayList to get an Object, and the second For loop goes through the ArrayList again seeing if that Object is found in another place in the ArrayList.
B) (Fun Way) For Loop that goes through entire ArrayList. For each instance, use the AbstractList.lastIndexOf(Object o) method. If the returned index is not equal to current index, remove the object in the returned index and check for the current object in the ArrayList again. Once the returned index is equal to the current index, you know that Object is not repeated in the ArrayList anymore.