Probably has a simple solution but I couldn't see it.
I still get an "unchecked" warning for this:
---
ArrayList<Decision> alDec = new ArrayList<Decision>();
...
// By the way, Decision implements Comparable interface
...
Collections.sort(alDecs); // here I get the unchecked warning
---
What am I missing?
thanks,
alex
o The actual code you tried to compile, preferably as a short,
complete, compilable example.
o The actual error given.
o Details of the Decision type.
I guess the error message is something like:
Dec.java:6: warning: [unchecked] unchecked method invocation:
<T>sort(java.util.List<T>) in java.util.Collections is applied to
(java.util.ArrayList<Decision>)
Collections.sort(alDecs);
^
1 warning
Note, javac doesn't tell us what the problem was. But if I reveal the
Decision class I broke to force the error:
abstract class Decision implements Comparable { }
There's your problem. The Comparable interface takes a generic
parameter, which is missing.
abstract class Decision implements Comparable<Decision> { }
Tom Hawtin
--
Unemployed English Java programmer
http://jroller.com/page/tackline/
Decision needs to implement Comparable<Decision> instead of
Comparable.
alex
>ArrayList<Decision> alDec = new ArrayList<Decision>();
>...
>// By the way, Decision implements Comparable interface
>...
>Collections.sort(alDecs); // here I get the unchecked warning
>-
You sail alDec in the first line and alDecs in the second.
Your Comparable needs to be generified too. See
http://mindprod.com/jgloss/sort.html
http://mindprod.com/jgloss/comparable.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.