接口回调

    技术2025-10-08  3

     

     

    interface ShowMessage

    {

    public void showmsg(String s);

    }

     

    class TV implements ShowMessage

    {

    public void showmsg(String s)

    {

    System.out.println(s);

    }

    }

    class PC implements ShowMessage

    {

    public void showmsg(String s)

    {

    System.out.println(s);

    }

    }

    public class hello {

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    ShowMessage sm;

    sm=new TV();

    sm.showmsg("tv/n");

    sm=new PC();

    sm.showmsg("pc/n");

    }

    }

     

    最新回复(0)