|
|
Subject:
java programming
Category: Computers > Algorithms Asked by: larryj10-ga List Price: $2.00 |
Posted:
14 Feb 2006 16:25 PST
Expires: 16 Mar 2006 16:25 PST Question ID: 445852 |
How do you write a merge() method in java so you can merge two ordered source arrays into an ordered destination array. For duplicate values, only count once |
|
There is no answer at this time. |
|
Subject:
Re: java programming
From: muruganantham-ga on 17 Feb 2006 05:55 PST |
You can use the TreeSet (java.util) to add these two ordered sequence list into one. Caveat, you have to use the Comparable interface implemented for the objects that are part of your list. Say you have class A is in the list. Class A implements Comparable.... If you don't use the Comparable, TreeSet would do a natural sorting by itself. But it will keep only the unique object (even for this you need to have the comparable implemented in your class). Here is the link for you on Comparable http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |