Hi,
My first post here...
As I read the code:
In Main you create a comparator "Comparator comp =
MyComparators.stringComparator();" this part use "return new Comparator()"
in "public static Comparator stringComparator() {".
Then comp contains the code (or pointer to code) "public int compare(Object
o1, Object o2) {...".
So when you call "Collections.sort(a1, comp);" you using the code for
"public int compare(Object o1, Object o2) {..." from comp and here is the
second return used.
Regards
Harri
Den tisdagen den 7:e januari 2014 kl. 22:33:22 UTC+1 skrev Sergio G
Barreros:
>
> Ok,
> as the subject of my first post states, This is from Lab 1016(5.2) Sort a
> list using Comparator. In that lesson, there is a class named
> MyCompartors.class, that class contains a method called stringComparator()
> .
> 1) The first line of that method is a return statement and there is
> another one at the bottom of the same stringComparator() method. Why does
> it have multiple return statements?
> 2) The Main.java file calls on the MyComparators.stringComparator(); method,
> but never uses the compare(Object o1, Object o2) method which i s the
> only method there. Please provide explanation on this.
>
> Code should be available on the Collections labs, but I am attaching them
> here anyway.
>
> On Monday, January 6, 2014 2:15:36 PM UTC-5, Deepak A L wrote:
>>
>> hi.
>> how does it work...confused.
>>
>> attach the working example team of jpassion with correct explanation....
>>
>> Regards,
>> Deepak
>> On Jan 6, 2014 12:14 AM, "Sergio G Barreros" <[email protected]> wrote:
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/groups/opt_out.