接口

package frank;
public class App implements Person
{
	public static void main(String[] args)
	{
		App ct = new App();
		System.out.println(Person.AGE);
	}
	public void get(){};//实现接口,不实现接口的话就只能定义成抽象类。
}
interface Person extends Person2
{
	public static final int MAX_SIZE = 10;
	int AGE = 20;
	public abstract void get();
}
interface Person2
{
	int AGE = 10;//系统默认加上 public static final修饰符
	void get();//系统默认加上public abstract修饰符
}

  抽象类和接口都不能被实例化。接口中不能有构造函数,接口中所有成员都是public的,接口中也不能有初始化块,不能有实现的方法。

posted on 2013-08-07 10:47  wp456  阅读(210)  评论(0)    收藏  举报

导航