我是Java的初学者,我正在尝试编译一些小程序,有人可以解释一下,我的问题是什么,提前谢谢:
public abstract class SumFunction<Y,X> {
public abstract Y op (Y y, X x);
}
public class sumStringToInt extends SumFunction{
public int op(int num, String s){
return s.length() + num;
}
}
Run Code Online (Sandbox Code Playgroud)
Multiple markers at this line
- The type sumStringToInt must implement the inherited abstract method SumFunction.op(Object,
Object)
- SumFunction is a raw type. References to generic type SumFunction<Y,X> should be
parameterized
Run Code Online (Sandbox Code Playgroud)
是否有可能在Java继承而没有实例化Base类?,提前感谢
你表明这SumFunction<Y,X>是两个参数.
因此,您的课程应如下所示:
public class sumStringToInt extends SumFunction<Integer,String> {
public Integer op(Integer num, String s){
return s.length() + num;
}
}
Run Code Online (Sandbox Code Playgroud)
试试......