I am have trouble to fix this up.Please help me out with your valuable suggestion.
I have an arrayList having many objects.I am saving the details of these objects in Xml format.I am trying to place the objects of same class inside a tag<class id="--"> details </class> My code prints the similar object details twice.I could understand that its because the checking is being done in both loops.But when i do it using a single for loop i have difficulty placing the tags properly.I am providing a rough format of my code.Please suggest me how can i accomplish this idea efficiently.
Sort your "arraylist" based on your key ("details.source"). This has a O(n lg n) complexity as opposed to the O(n ^ 2) complexity that your implementation currently has.
Now print out your arraylist. You should have what you want.
HTH, - Anand
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
Ernest Friedman-Hill
author and iconoclast
Marshal
I notice that your signature file is rather long compared to what we usually see here at the ranch -- it's longer that your post in this thread, and longer than many posts in many threads, come to think of it. The fact that it's mostly code makes it especially distracting and makes threads in which it appears hard to read.
The worst part is that people rapidly tire of seeing the same joke over and over again.
Please, as soon as you can, head here and clean yours up, please; a single line would be most appropriate. Thanks.
Anitha, See this works for you, and I have used this in my applicatin.
---------------------------
Initialize a HashMap <hashMap>. Create a ArrayList similarObjList; int i=0; int indicator=0; Details details; while i< ArrayList.size() { Object k=ArrayList.get(i);