两个接口为:public interface Contents
{
int value();
}public interface Destination
{
String readLabel();
}一个包含内部类的类为:
public class Goods
{
private class Content implements Contents
{private int i=11;
public int value()
{
return i;
}
}
protected class GDestination implements Destination
{
private String label;
private GDestination(String whereTo)
{
label=whereTo;
}
public String readLabel()
{return label;
}
}
public Destination dest(String s) {return new GDestination(s);
}
public Contents cont() {return new Content();
}
}这两句作何理解,public+接口名+方法?这是什么?是实现接口吗?但是接口中无此方法啊?
{
int value();
}public interface Destination
{
String readLabel();
}一个包含内部类的类为:
public class Goods
{
private class Content implements Contents
{private int i=11;
public int value()
{
return i;
}
}
protected class GDestination implements Destination
{
private String label;
private GDestination(String whereTo)
{
label=whereTo;
}
public String readLabel()
{return label;
}
}
public Destination dest(String s) {return new GDestination(s);
}
public Contents cont() {return new Content();
}
}这两句作何理解,public+接口名+方法?这是什么?是实现接口吗?但是接口中无此方法啊?
}public Contents cont() {return new Content();
}两个普通方法,返回实现了接口的类的对象
public+接口名+方法 接口名就是返回类型啊