Defined interfaces

What is the interface

package com.wyq.study;

public abstract class Inter {
	public abstract void show();
	public abstract String fun();
	public abstract int [] method();
	public abstract Person [] perlist();
}
public interface Interr{
	void show();
	String fun();
	int [] method();
	Person [] perlist();
}

1, the origin of the mouth solution, there is the class methods are all abstract methods, but also the class is an abstract class, then the class program to the interface

2, the interface can be inherited multiple inheritance

3, the interface is needed to achieve the sub-class, sub-class can not implement the interface if the parent class, then subclass must be abstract class

4, the interfaces may be variable, but the variables are to be public static final modification flies, while public static final usually can be omitted. Therefore, these variables are also constants, defined when it should be initialized

5, before jdk1.8, the interface method is not allowed body

6, the interface can not create objects, interfaces can not define a constructor method, because the interface is not a class

7, if there is both a class inheritance, and there realize the relationship, then this should be the first class inheritance, after realization

8, a class can inherit from a parent class, but can implement multiple interfaces N

Guess you like

Origin blog.csdn.net/wyqwilliam/article/details/91903515