intermediate/LengthComparator

From ggc

Jump to: navigation, search

01 package intermediate;
02 //start auto-imports
03 import java.util.*;
04 //end auto-imports
05 
06 
07 /**
08  * All about my helper class.
09  @author My Name Here
10  */
11 public class LengthComparator extends Object
12       implements Comparator<String>
13 {
14   public int compare(String a, String b)
15   {
16     if(a==null && b==null)
17       return 0;
18     else if(a==null)
19       return -1;
20     else if(b==null)
21       return 1;
22     return a.length()-b.length();
23   }
24 
25   public String toString()
26   {
27     return "I am a happy length comparator: "+super.toString();
28   }
29 }


Download/View intermediate/LengthComparator.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter