• 接口(字母大小写)


    编写2个接口:InterfaceA和InterfaceB;在接口InterfaceA中有个方法void

    printCapitalLetter();在接口InterfaceB中有个方法void printLowercaseLetter();然

    后写一个类Print实现接口InterfaceA和InterfaceB,要求printCapitalLetter()方法

    实现输出大写英文字母表的功能,printLowercaseLetter()方法实现输出小写英文

    字母表的功能。再写一个主类E,在主类E的main方法中创建Print的对象并赋

    值给InterfaceA的变量a,对象a调用printCapitalLetter方法;最后再在主类E

    的main方法中创建Print的对象并赋值给InterfaceB的变量b,对象b调用

    printLowercaseLetter方法。


    package zuoye0923;

    public interface InterfaceA {
    void
    printCapitalLetter();

    }
      


    package zuoye0923;

    public interface InterfaceB {

    void printLowercaseLetter();
    }
      


    package zuoye0923;

    //实现接口InterfaceA, InterfaceB
    public class Prin implements InterfaceA, InterfaceB {

    @Override
    public void printLowercaseLetter() //实现小写
    {
    String xiao="abcdefghijklmnopqrstuvwxyz";
    System.out.println(xiao);

    }

    @Override
    public void printCapitalLetter() //实现大写
    {
    String da="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    System.out.println(da);

    }

    }
      


    package zuoye0923;

    public class E {
    //测试
    public static void main(String[] args) {
    Prin x=new Prin();
    InterfaceA a=new Prin();
    a.printCapitalLetter();

    InterfaceB b=new Prin();
    b.printLowercaseLetter();



    }

    }

  • 相关阅读:
    c++ STL中的vector与list为什么没有提供find操作?
    转发:CAOZ星球提问。 遇到很大瓶颈,想离职又不敢离职怎么办
    转发 :caoz:数据分析这点事
    那些绕不开的Linux
    记录 《 Bootstrap 基础教程》 学习笔记 第一天
    迈出你的第一步——天助自助者
    this指向问题
    小结
    前端小白的福利
    真实案例分享
  • 原文地址:https://www.cnblogs.com/smile-dream/p/5902412.html
Copyright © 2020-2023  润新知