日期:2014-05-20  浏览次数:20861 次

java接口问题,,看代码
Java code

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package study;

/**
 *
 * @author Administrator
 */
public class Interfa {
    static void r(CanRead cr){
        cr.readMagazine();
        cr.readPaper();
    }
    static void l(CanListen cl){
        cl.listenBook();
        cl.listhenRadio();
    }
    static void f(CanFeel cf){
        cf.feelCold();
        cf.feelWarm();
    }
    static void al(CanAll ca){
        ca.feelCold();
        ca.feelWarm();
        ca.readMagazine();
        ca.readPaper();
        ca.listenBook();
        ca.listhenRadio();
    }
    
    public static void main(String[] args){
        Animal an=new Animal();
        r(an);
        f(an);
        l(an);
        al(an);
    }
    
}
interface CanRead{
    void readPaper();
    void readMagazine();
}
interface CanListen{
    void listhenRadio();
    void listenBook();
}
interface CanFeel{
    void feelWarm();
    void feelCold();
}
interface CanAll extends CanRead,CanListen,CanFeel{
    void all();
}
class Animal extends  Ashow implements CanAll{

    @Override
    public void all() {
        System.out.println("all()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void readPaper() {
        System.out.println("readPaper()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void readMagazine() {
        System.out.println("readMagazine()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void listhenRadio() {
        System.out.println("listenRadio()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void listenBook() {
        System.out.println("listenBook()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void feelWarm() {
        System.out.println("feelWarm()");
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void feelCold() {
        System.out.println("feelCold()");
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
class Ashow{
    void show(){
        System.out.println("hello Ashow");
    }
}


出现的问题如下
run:
readMagazine()
Exception in thread "main" java.lang.UnsupportedOperationException: Not supported yet.
at study.Animal.readMagazine(Interfa.java:74)
at study.Interfa.r(Interfa.java:13)
at study.Interfa.main(Interfa.java:35)
Java Result: 1
成功生成(总时间:0 秒)

为什么只有一个方法打印信息

------解决方案--------------------
建议使用Eclipse
------解决方案--------------------
晕,都在方法里直接抛出了啊,这还发帖子问。