我已经实现接口B.接口没有setter方法
B ref = new A();
代码的具体类答:
public interface B{
public abstract String[] getWords();
}
public class A implements B {
private String[] words = new String[] {};
public void setWords(String[] words){
this.words = words;
}
public String[] getWords(){
return this.words;
}
}
在接口B,我只有getter方法,但不虽然A类有这个方法
所以,当我这样做:B ref = new A();
,这个代码将工作,我将如何设置单词?
感谢所有的答复。 – Mercenary