编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然 后写一个类Print实现接口InterfaceA和InterfaceB,最后再在主类E 的main方法中创建Print的对象并赋值,运行方法

package lianxi;

public interface InterfaceA {
    void printCapitalLetter();


}
package lianxi;

public interface InterfaceB {
    void printLowercaseLetter();
}
package lianxi;

public class Print1 implements InterfaceA, InterfaceB {

    @Override
    public void printLowercaseLetter() {
        for (int i = 97; i < 123; i++) {
            System.out.print((char)i);
            
            
        }
           System.out.println();
    }

    @Override
    public void printCapitalLetter() {
        for (int i =65; i < 91; i++) {
            System.out.print((char)i);
            
        }
           System.out.println();
    }

}
package lianxi;

public class E {

public static void main(String[] args) {

     InterfaceA a=new Print1();
     InterfaceB b=new Print1();
     a.printCapitalLetter();
     b.printLowercaseLetter();
    
    
}
    

}

posted @ 2016-05-24 14:26  凌零聆  阅读(2903)  评论(0编辑  收藏  举报