Search:

Type: Posts; User: Minken

Search: Search took 0.18 seconds.

  1. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    @copeg - Thanks! that worked like a charm! =)
  2. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    Ah thanks helloworld922! That solved my problem! =)

    Now another question, if I wish to search for a title in the arraylist, is there a simple way to do this?
  3. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    Rewrote the comparable code to:
    public int compareTo(Book objekt) {
    if (objekt.getTitle().compareTo(this.getTitle()) < 0) {
    return 0;
    } else if...
  4. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    Ah yes this is confusing =/

    But since I do use the Comparable class with:
    public class Book implements Comparable<Book>

    I can't see the problem by using
    List<Book> temp = cob.remoteSort();...
  5. Replies
    12
    Views
    10,882

    Re: Collection.sort problem

    It is correct, however I see that the error is that i only pass the List to be sorted and not what method to be used with comparable. So it should look something like this:

    Pseudo-code:
    ...
  6. Replies
    12
    Views
    10,882

    Collection.sort problem

    Hi I'm having problems with java and the collections.sort method. I can't figure out how to sort an arraylist using the compareTo and Comparable interface. I've created the compareTo method and so...
Results 1 to 6 of 6