JAVA: override interface method

interface, java, methods, overriding

Solution

Don't add a type parameters to the interface and the type. Also you should specify the generic parameters of the interface you implement:

interface operations<T> {  
    void sum(T t);  
}



class matrix implements operations<matrix> {  
    @Override   
    public void sum(matrix m){  
    } 
}



class vector3D implements operations<vecor3D> {  
    @Override  
    public void sum(vecor3D v){  
    }
}

Problem

I have interface: ``` interface operations{ void sum(); } ``` and I want to have classes: ``` class matrix implements operations { @override void sum(matrix m) { } } class vector3D implements operations { @override void sum(vecor3D v) { } } ``` How to do this? I tried something like this: ``` interface operations < T > { <T> void sum(T t); } class matrix implements operations<matrix>{ @Override void sum(matrix m){}; } } class vector3D implements operations<vector3D>{ @Override void sum(vector3D v){}; } ``` but it doesn't work.

Original source