Google Answers Logo
View Question
 
Q: java programming ( No Answer,   1 Comment )
Question  
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
Answer  
There is no answer at this time.

Comments  
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

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

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 Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy