Guys..
I am trying to figure out Comparator so I can compare Strings in an object array (the object has other data types as well).
I have been hunting around and have come up with this.. but I cant get it to work --> Can anyone point me in the right direction.. (if find the javadoc on the Comparator class is not very helpful)
public class NameComparator implements Comparator
{
public static int compareNames(BankCustomer customerOne, BankCustomer customerTwo)
{
String CustomerOneName = customerOne.getFullName();
String CustomerTwoName = customerTwo.getFullName();
return(CustomerOneName.compareTo(CustomerTwoName));
}
}
Or how do I just call it from within my main class?
I tried Comparator c = new Comparator(); and also all other combos.. but i am a bit lost here...
anyone?