Suna Dev wrote:that is the my own code. exactly i want to merge "link" to "link2", link3 = (A, B, C, D, E, F).
It sounds to me like you're being far too literal about these things.
Merging is a generic problem, so you really shouldn't be worrying about whether the list is "linked" or not. The chances are that your solution should look something like:(don't forget that LinkedList ––IS-A→ List ––IS-A→ Collection. The output must be a List, because it has a specific order)
About the only thing that's missing from the above declaration is how you want to merge (ie, what defines the output order), and you can supply that with a Comparator (java.util.Comparator). So your final method might well look something like:indeed, one might ask why such a method wasn't included in java.util.Collections.
I'll leave you to think about how you might implement it.
And after that The reverse of the queue will be (F, E, D, C, B, A) so how to do that? please help me.
Reversal has nothing to do with merging. Assuming you have a "merged" List, you can easily gets its elements in reverse sequence by using its ListIterator.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop