So, the notation is wrong. I need to create Comparator classes that will sort my ArrayList of Items by title ...
Type: Posts; User: knowNothing23
So, the notation is wrong. I need to create Comparator classes that will sort my ArrayList of Items by title ...
Well, if you guys want to help me analyze it, while I do it on my own that would be even better.
package assignment3;
import java.util.Calendar;
import java.util.Date;
import...
I need to evaluate the rest of the code on my own. Maybe, I can get it to work. Thank you very much. I will keep you guys up to date with any progress.
Thank you aussiemcgr.
So, I have Item that implements the "Collections" Comparable interface and Textbook extends Item. I will not modify the compareTo() in Textbook yet
Thank you for trying to...
I erased my own Comparable class and now the code compiles a little further. It now crashes later and shows this:
----- DATABASE BEFORE SORTING: -----
DataBase.list has been called...
I get this when I implement Comparable<Textbook> in the Textbook class:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The interface Comparable cannot be implemented...
There's no reason, why Textbook implements it. I read somewhere that this should not matter and I had this same problem, before I implemented this to Textbook.
// sort and print sorted database (by id)
Collections.sort( library.getItem() );//uses Collections class
When removing (ArrayList), I get the error:
Exception in thread "main"...
The title says it all. I get the following error:
Exception in thread "main" java.lang.ClassCastException: assignment3.Textbook cannot be cast to java.lang.Comparable
at...