Unable to find a method belonging to an object

前端 未结 2 1528
旧巷少年郎
旧巷少年郎 2021-01-22 03:54

I believe I am making a really simple mistake/ overlooking something trivial.

import java.util.Comparator;

public class NaturalComparator {

            


        
2条回答
  •  天涯浪人
    2021-01-22 04:16

    You accidentally created a generic type parameter Integer which has nothing to do with the Integer class, and you didn't implement Comparator. Try

    public class NaturalComparator implements Comparator
    

    Placing an identifier in <> on the class declaration declares a generic type parameter, but placing an identifier in <> on the implements/extends clause is a passing a type argument.

提交回复
热议问题