[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Comparing 2 ArrayLists and extracting values which are not common

Posted on 2007-07-24
Medium Priority
Last Modified: 2012-06-21
I have 2 ArrayLists

I want to compare them and extract uncommon items.
Basically want to get rid of common items.

Please guide
Question by:jaipur07

Accepted Solution

NHBFighter earned 2000 total points
ID: 19556919
Here is a way,
            ArrayList al1=new ArrayList();
            ArrayList al2=new ArrayList();
            ArrayList unique=new ArrayList();
            for(int i=0;i<al1.size();i++){
            for(int i=0;i<al2.size();i++){
LVL 86

Expert Comment

ID: 19557165
Implement Comparable or use a Comparator


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question