Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: Comparator ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 11 Topic 16040 of 16078
Post > Topic >>

Re: Comparator in the driver

by thufir <hawat.thufir@[EMAIL PROTECTED] > Apr 30, 2008 at 12:51 PM

On Wed, 30 Apr 2008 12:35:32 +0000, thufir wrote:


> Due to the requirements, I can only use a Comparator for the last name
> (rather than for City as I had mentioned in my post).  I'd like to move
> the Comparator outside of the driver, but for now it's fine where it is.

ROFL -- I had some dummy data in there, I was returning 0 regardless of 
anything else!   Seems to work now(just have to clean up):

thufir@[EMAIL PROTECTED]
 
thufir@[EMAIL PROTECTED]
 cat -n src/a00720398/labs/Lab3.java 
| head -n 90 | tail -n 12
    79          static final Comparator<Guest> BY_NAME = new 
Comparator<Guest>(){
    80                  public int compare(Guest g1, Guest g2){
    81                          ContactInfo c1 = g1.getContactInfo();
    82                          ContactInfo c2 = g2.getContactInfo();
    83                          System.out.println("******************");
    84                          String s1 = c1.getLastName();
    85                          String s2 = c2.getLastName();
    86                          int foo = s1.compareTo(s2);
    87                          System.out.println(foo);
    88                          return foo;
    89                  }
    90          };
thufir@[EMAIL PROTECTED]
 


I'd like to put this Comparator into a00720398.util.CollectionUtil and 
still keep the collections in the driver to meet other requirements.

Any pointers as to how to do that?



thanks,

Thufir




 11 Posts in Topic:
Comparator in the driver
thufir <hawat.thufir@[  2008-04-30 08:11:35 
Re: Comparator in the driver
"Matt Humphrey"  2008-04-30 07:51:59 
Re: Comparator in the driver
thufir <hawat.thufir@[  2008-04-30 12:35:32 
Re: Comparator in the driver
thufir <hawat.thufir@[  2008-04-30 12:51:54 
Re: Comparator in the driver
Lew <lew@[EMAIL PROTEC  2008-04-30 21:15:06 
Re: Comparator in the driver
Roedy Green <see_websi  2008-04-30 13:43:44 
Re: Comparator in the driver
Thufir <hawat.thufir@[  2008-04-30 16:29:40 
Re: Comparator in the driver
Roedy Green <see_websi  2008-05-02 10:56:20 
Re: Comparator in the driver
thufir <hawat.thufir@[  2008-05-01 17:01:32 
Re: Comparator in the driver
Lew <lew@[EMAIL PROTEC  2008-05-01 18:23:34 
Re: Comparator in the driver
thufir <hawat.thufir@[  2008-05-02 04:57:13 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 11:24:35 CDT 2008.