インターフェイスBを実装する具象クラスAがあります。
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では、クラスAにはゲッターメソッドがありますが、セッターメソッドはありません。
だから私がこれを行うとき:B ref = new A();
、このコードは機能し、どのように単語を設定しますか?