Suppose I got this interface A:
interface A
{
void doThis();
String doThat();
}
So, I want some class theses to implement the doThis () method, but not doThat () one:
abstract class B implements A
{
public void doThis()
{
System.out.println("do this and then "+ doThat());
}
}
abstract class B2 implements A
{
public void doThis()
{
System.out.println(doThat() + "and then do this");
}
}
The error occurs when you decide to implement the doThat method in a regular class:
public class C implements B
{
public String doThat()
{
return "do that";
}
}
This class leads me to the above error:
"Type B cannot be a superinterface C, but a superinterface must be an interface"
Could anyone now if this class hierarchy is valid or should I do the opposite?
source
share