i wanaa compare 2 array list and find the uncommon data in 3rd arry list
i have written below code

    ArrayList db2Crns=new ArrayList();      
    ArrayList oracleCrns=new ArrayList();
    ArrayList leftOverCrns=new ArrayList();
    db2Crns=testDB2Connect.getDb2LoggedInCrns();
    oracleCrns=testOracleConnection.getDataFromPartyAuditInfo();

    int array1Size = db2Crns.size();  
    int array2Size = oracleCrns.size();
    System.out.println(db2Crns.size());
    System.out.println(oracleCrns.size());
    for(int i=0;i<oracleCrns.size();i++)
    {   
        String val=oracleCrns.get(i).toString();
        int k=0;

        for(int j=0;j<db2Crns.size();j++)
        {

            if(oracleCrns.get(i)==(db2Crns.get(j)))
            {
                    k++;        
            }   
        }

        leftOverCrns.add(val+k);

    }
    System.out.println(leftOverCrns.size());

 /* for(int x=0;x<leftOverCrns.size();x++)
    {
        System.out.println(leftOverCrns.get(x));
    }*/

o/p is : 
13494
11529
11529

BUT REQUIRED OUTPUT IS:
11524
13494
1970(13494 - 11524)

please do the needful.

- Clone the first arraylist into a third arraylist
- Call removeAll on the third arraylist using the second arraylist
- Clone the second arraylist into a fourth arraylist
- Call removeAll on the fourth arraylist using the first arraylist
- Call addAll on the third arraylist using the fourth arraylist
The third arraylist is now your end result. That is, if you need to retain the original two list.

If you not need to retain the original lists
- Clone the first arraylist to a third arraylist
- Call removeAll on the third arraylist using the second arraylist
- Call removeAll on the second arraylist using the first arraylist
- Call addAll on the third arraylist using the second arraylist
The third is, again, the result.

hi, i am fresher i have been given this task i tried alot.....
i dont know anything in java
can u plz tell me the code changes which i need to do
kindly help

No. Read my post again, read the api docs, and give it a try. This is not a homework service.

ArrayList<Integer> one=new ArrayList<Integer>();
            one.add(1);
            one.add(2);


            ArrayList<Integer> two=new ArrayList<Integer>();
            two.add(6);
            two.add(2);
            two.add(1);
            two.add(3);
            two.add(5);




            ArrayList<Integer> addition=new ArrayList<Integer>();




            for(int i=0;i<one.size();i++)
            {
                int x=one.get(i).intValue();
                int y=two.get(i).intValue();


                if(x!=y)
                {

                addition.add(one.get(i));
                addition.add(two.get(i));
                }else if(x==y){
                    addition.add(two.get(i));
                    }

            }
            int lastIndexOfOne=one.size();
        for(int i=lastIndexOfOne;i<two.size();i++)
            {
            if(addition.contains(two.get(i)))
            {continue;}else
                addition.add(two.get(i));
            }


        System.out.println("Before");
        for(Integer i:addition)
        {
            System.out.println(+i);
        }



            for(int i=0;i<one.size();i++)
            {

                if(addition.contains(one.get(i)))
                {
                addition.remove(one.get(i));    
                }

            }

            System.out.println("After");
            for(Integer i:addition)
            {
                System.out.println(+i);
            }


    }






}

And your question is?

And were you not allowed to use the addAll/removeAll methods? Or did you simply not try, or did you simply not check that the methods exist at all and assumed something else from what I said?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.