• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Collection sort

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


30
12
7
7
-5



I read this code in this book:
SCJP
Sun Certified Programmer
for Java® Platform, SE6
Study Guide
I can't understand how Reverse method work, so How these numbers are sorted?
 
Marshal
Posts: 80217
423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Reverse method? There isn't a Reverse() method anywhere. You are creating a Reverse object. What can you not see about its workings? You have got the whole class there in front of you Go through it with a pencil and paper and see how it works.
 
Greenhorn
Posts: 14
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, try changing the compare method by switching the o1 and o2 around in the return statement. That should give you a clue of what is happening.

Like this:


 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Read the API documentation of the Collections.sort(List, Comparator) method and of java.util.Comparator.
 
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic