From: Roedy Green on 18 Jun 2010 22:03 On Tue, 15 Jun 2010 21:39:22 -0700 (PDT), Arthi J <arthi.j(a)gmail.com> wrote, quoted or indirectly quoted someone who said : >public int compareTo(Object o) { >return 1; this is a dummy compareTo. It is just a placeholder until the proper code is inserted. see http://mindprod.com/jgloss/compareable.html -- Roedy Green Canadian Mind Products http://mindprod.com There is no harm in being sometimes wrong especially if one is promptly found out. ~ John Maynard Keynes (born: 1883-06-05 died: 1946-04-21 at age: 62)
From: Christian Kaufhold on 13 Jul 2010 15:33 Roedy Green <see_website(a)mindprod.com.invalid> wrote: > On Tue, 15 Jun 2010 21:39:22 -0700 (PDT), Arthi J <arthi.j(a)gmail.com> > wrote, quoted or indirectly quoted someone who said : > >>public int compareTo(Object o) { >>return 1; > > this is a dummy compareTo. It is just a placeholder until the proper > code is inserted. Then it should use return 0; as that is at least a consistent implementation (only one equivalence class).
From: Eric Sosman on 13 Jul 2010 15:45
On 7/13/2010 3:33 PM, Christian Kaufhold wrote: > Roedy Green<see_website(a)mindprod.com.invalid> wrote: > >> On Tue, 15 Jun 2010 21:39:22 -0700 (PDT), Arthi J<arthi.j(a)gmail.com> >> wrote, quoted or indirectly quoted someone who said : >> >>> public int compareTo(Object o) { >>> return 1; >> >> this is a dummy compareTo. It is just a placeholder until the proper >> code is inserted. > > Then it should use > return 0; > as that is at least a consistent implementation (only one equivalence class). Still better, IMHO, is public int compareTo(Object o) { throw new UnsupportedOperationException("FIX ME!"); } (This is approximately what NetBeans generates for you when you tell it to implement the missing methods required by an interface or by an abstract superclass.) -- Eric Sosman esosman(a)ieee-dot-org.invalid |