Search:

Type: Posts; User: aussiemcgr

Search: Search took 0.21 seconds.

  1. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    Well, since you already have Book as Comparable, the List.indexOf(Object o) method might work.

    (Might work, not sure)
    Say you wanted to search for a Book with the title: "Java"
    Since your...
  2. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    Here is a possibility:
    The compareTo method is supposed to return a -1,0,or 1. However, in your compareTo method, you only return a 0 and a 1. I do not know if it will make a difference, but it is...
  3. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    That is incorrect. There are two sort methods in the Collections API:
    1:


    2:


    Now, there are two different classes that have similar names. 1 is the Comparable Class and the other is the...
  4. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    I haven't used Comparable extensively, but I'll provide what help I can.

    The line where you are sorting is this, correct:

    Collections.sort(temp);


    If so, you seem to be attempting to use...
Results 1 to 4 of 4