3,定义实现类
Main
package com.org.test;
public class Main implements Some,Other{
public static void main(String[] args) {
System.out.println(Some.x);
System.out.println(Some.y);
Some some=new Main();
some.doSome();
Other other=(Other)some;
other.doOther();
//接口的匿名内部类实现doSome方法并在内部类中添加匿名内部类的doService方法
Some some2=new Some() {
@Override
public void doSome() {
System.out.println("Some2:做一些!");
} public void doService(){
System.out.println("Some2:做一些服务!");
} }; }
@Override public void doSome() {
System.out.println("Main:doSome");
}
@Override public void doOther() {
System.out.println("Main:doOther");
}}