Test 接口:
package fuyou;
public interface Test {
public void show(String string);
}TestIn 类实现了 Test 接口:
package fuyou;public class TestIn interface Test{ //这有错误
public static void main(String [] args){观点 //这也错误
Test ti = (test)new TestIn();
ti.show("fuyou");
}
public void show(String s){
System.out.println(s);
}
}为什么会有这个错误:
package fuyou;
public interface Test {
public void show(String string);
}TestIn 类实现了 Test 接口:
package fuyou;public class TestIn interface Test{ //这有错误
public static void main(String [] args){观点 //这也错误
Test ti = (test)new TestIn();
ti.show("fuyou");
}
public void show(String s){
System.out.println(s);
}
}为什么会有这个错误:
package fuyou;
public interface Test {
public void show(String string);
}TestIn 类实现了 Test 接口:
package fuyou;public class TestIn interface Test{ //这有错误
public static void main(String [] args){ //这也错误
Test ti = (test)new TestIn();
ti.show("fuyou");
}
public void show(String s){
System.out.println(s);
}
}为什么会有这个错误:
接口是用来实现的,这里不能用interface 而是用implements
如果是类的话,则空extends
....
....}