假设有这样的代码:
package com.ps.Sample;
public interface Sample
{
public void Method1();
}
public abstract class AbstractSample implements Sample
{
public void Method1()
{
System.out.println("Hello World");
}
}
public class MySample extends AbstractSample
{
}
public class TestSample
{
public static void main(String[] args)
{
Sample my = new MySample();
my.Method1();
}
}
我的问题是:将具体类声明为
public class MySample extends AbstractSample implements Sample
代替
public class MySample extends AbstractSample