import java.util.*;
class pqr
{
public static void main(String ab[])
{
List<Integer> ts=new ArrayList<Integer>();
for(int i=0;i<10;i++)
ts.add((int)(Math.random()*1000));
System.out.println(ts);
class RSO implements Comparator<Integer>
{
public int compare(Integer i,Integer j)
{
return j-i;
}
}
RSO rs=new RSO();
Collections.sort(ts,rs);
System.out.println(ts);
Comparator fs=(Comparator<Integer>)Collections.reverseOrder(rs); // Same result with casting or without casting
Collections.sort(ts,fs);
System.out.println(ts);
}
}
このコードは期待どおりの結果を示していますが、コンパイル中に末尾から 5 行目に次の警告メッセージが表示されます。
Note: 5.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
キャストの有無にかかわらず同じ警告が表示されます。警告を削除するのを手伝ってください。