Welcome Guest ( Log In | Register )



3 Pages V  < 1 2 3  
Reply to this topicStart new topic
> Array Sorting, Does anyone hava a decent JAVA method
java-area
post Apr 9 2008, 02:17 PM
Post #21


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 47
Joined: 4-February 08
Member No.: 28,119



QUOTE(ykf @ May 14 2005, 12:21 PM) *
He can always implement Comparator interface to do virtually ANYTHING he want. So I wonder why he wants to reinvent the wheels... after all, libraries are tools which makes you NOT to redo what was already done.


I think it is the best solution, provided by Java API - we can simply put desirable business logic of sorting into the method "Comparator::compare()".
I do not any reasons to invent anything else.

For example:

import java.util.Comparator;

public class MyItem implements Comparator {

.......

public int compare(Object o1, Object o2) {
// your business logic of sorting
}

public boolean equals(Object obj) {
// see Sun comments here
}
}

So, we can put objects of MyItem class into appropriated collections (for example, any implementation of SortedSet interface: TreeSet etc.)
Go to the top of the page
 
+Quote Post

3 Pages V  < 1 2 3
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. java.lang.NullPointException(4)
  2. Java Unlimited(14)
  3. What Are The Advantages Of Java Vs C++?(15)
  4. Need Help: Find Lowest Character Using Java(6)
  5. Download Java Ebooks(13)
  6. Video Streaming In Web Browser Through Java Or Jsp(1)
  7. Looking For A Java IDE(24)
  8. Java App To Web App(12)
  9. On Why Java Is 'c'ooler!(10)
  10. How To Configure/intergrate Jboss 4 With Java?(1)
  11. Snake In Java(2)
  12. Other Sound Format Support(3)
  13. Java Phone Book(2)
  14. How To Create Exe File In Java?(12)
  15. How Do I Test A Java Aplication(11)
  1. Mozilla And Java!(2)
  2. Need To Modify Xml Attribute Using Java(4)
  3. Bluetooth And Java(5)
  4. Java Sdk Vs. Java Jdk?(2)
  5. Graphcal User Interfaces In Java(4)
  6. Java Db Help Pls(2)
  7. Loading 3d Models In Java?(2)
  8. Java Applet Loading Error(5)
  9. Setting Up Java Correctly(8)
  10. Java Java.security.accesscontrolexception(6)
  11. Simple Java Question(1)
  12. Java And Sql: Data Mismatch(6)
  13. Java Memory Leak?(0)


 



- Lo-Fi Version Time is now: 22nd August 2008 - 01:50 AM