Java – Abstract generic class

I have the following courses:

public abstract class Step {
    public abstract <S,T> S makeAStep(S currentResult,T element);
}

I'm trying to implement it, so it needs two ints and returns the sum of them, as follows:

public class sumOfInts extends Step {
    public <Integer,Integer> Integer makeAStep(Integer currentResult,Integer element){
        return currentResult + element;
    }
}

But I received the following error:

Please help me (I need it for my programming language course homework)

I am very friendly to write a code to complete the code I want to complete. There are any errors or warnings. Thank you

Solution

public abstract class Step<S,T> {
public abstract class Step<S,T> {
    public abstract S makeAStep(S currentResult,T element);
} 

public class SumOfInts extends Step<Integer,Integer> {
    // etc.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>