Unchecked Method Invocation Warning

Last time (16 April 2008) I reported the following warning:

C:\prog\finalgame>javac -Xlint:unchecked board.java
board.java:87: warning: [unchecked] unchecked method invocation:
sort(java.util.List)in java.util.Collections is applied to
(java.util.ArrayList)Collections.sort(collisions);
                                    ^
1 warning

Original Code

087:                     Collections.sort(collisions);

which was called for an ArrayList of Collision objects

001: public class Collision implements Comparable

029:     public int compareTo(Object other)
030:     {
031:         Collision c = (Collision) other;
032:         if (timestep>c.timestep) return 1;
033:         if (timestep<c.timestep) return -1;
034:         return 0;
035:     }
036:

Modified Code

01: public class Collision implements Comparable<Collision>

29:     public int compareTo(Collision other)
30:     {
31:         if (timestep>other.timestep) return 1;
32:         if (timestep<other.timestep) return -1;
33:         return 0;
34:     }


Maintained by John Loomis, last updated 17 April 2008