Jeanne Boyarsky wrote:You've done the first step - define clearly what you wanted. Now the next step is to get started. Can you explain (in Java code or pseudocode or English) how you coudl use a loop to do this? For example:
1) look at the first entry
2) write down the following from it
3) look at the second entry
4) compare it to what is written down. if X matches, do Y. otherwise, do Z
Do post what you come up with here so we can hint at the next step.
K Abhijit wrote:there are multiple way you can handle this issue.
[MODERATOR ACTION: Deleted fully coded solution.]
K Abhijit, please remember that this site is NotACodeMill, and LetThemDoTheirOwnHomework. Thank you!
PrasannaKumar maddu wrote:By overriding Comparator OR Comparable interfaces methods you can achieve sorting your collection.Google the interfaces.
Your fist step is to figure out how you would do it "manually." What information do you need to keep track of? What operations do you need to perform? What decisions do you make? Describe the steps as precisely, thoroughly, and simply as possible, without regard to Java or computers--just as a general set of instructions. Once you have that, if you've done it correctly, translating it to Java will be relatively easy.