看到jdk某些接口中存在default方法,于是...
http://shaomeng95.iteye.com/blog/998820 为什么接口只能是公有常量?
public interface Jdk8新特性 {
    public static final String AA = "hhe";
    
    default void test(){
        System.out.println("哈哈");
    }
    
    public static void hehe(){
        System.out.println("没什么");
    }
}
public class TestMain implements Jdk8新特性 {
    public static void main(String[] args) {
        TestMain tm = new TestMain();
        tm.test();   //接口中的default方法会继承过来
    }
    public static void hehe(){
        System.out.println("哈哈");
    }
}
1 如果TestMain在实现一个接口,这个接口中也有test这个方法且是default修饰的,那么会出现什么问题?
 编译器会让你重写其中一个方法,否则不能通过编译
public class TestMain implements Jdk8新特性, Jdk8新特性2 {
    public static void main(String[] args) {
        TestMain tm = new TestMain();
        tm.test();
    }
    public static void hehe(){
        System.out.println("哈哈");
    }
    @Override
    public void test() {
        Jdk8新特性2.super.test();
    }
}
2 实现类中定义一个一样的静态方法有影响吗?
 没有影响,静态方法与类(接口)相关
 
        