今天看到在看DOM4J的源码是,在接口时,我看到一个很用意思的东西。
通常我们在理解接口时,是不能创建实体对象(即interface不能创建对象),但是接口可以创建接口数组
public interface Text{
void read();
}
public class TextImp implements Text{
通常我们在理解接口时,是不能创建实体对象(即interface不能创建对象),但是接口可以创建接口数组
public interface Text{
void read();
}
public class TextImp implements Text{
public void read(){
System.out.println("你好");
}
}
通常我们不能这样创建这样的对象,如Text t=new Text()。我们的这样创建对象Text t1=new TextImpl();
但是我们可以创建接口数组Text[] 1=new Text[12];