@copeg - Thanks! that worked like a charm! =)
Type: Posts; User: Minken
@copeg - Thanks! that worked like a charm! =)
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?
Rewrote the comparable code to:
public int compareTo(Book objekt) {
if (objekt.getTitle().compareTo(this.getTitle()) < 0) {
return 0;
} else if...
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();...
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:
...
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...