Collections.sort() 上未经检查的方法调用警告

Unckecked method invocation warning on Collections.sort()

我想对作为参数收到的 List<MyType> 进行排序:

static void doSomething(List<MyType> arg) {
    Collections.sort(arg);
}

...但我收到此警告:

Unchecked method 'sort(List<T>)' invocation

这是MyType

class MyType implements Comparable {
    private int number;

    public MyType(int n) {
        number = n;
    }

    public int compareTo(MyType b) {
        return Integer.compare(number, b.number);
    }
}

我可以抑制这个警告,但我想知道我做错了什么。

@Aominè 说得对:MyType 实现了 Comparable 而不是 Comparable<MyType>。现在我已经更改了警告,警告消失了。