-1

外側のクラスには、内側のインターフェイス、内側の抽象クラス、および内側のクラスがあります。

OuterClassのouterMethod()メソッドを呼び出すと、

AKindBiz クラスのメソッドは、リストの内容のみを出力できます。

抽象クラス (CommonKindBiz) のメソッドが何も出力できないのはなぜですか?

public class OuterClass {

    public void outerMethod( ) throws Exception{
        ArrayList<String> list = new ArrayList<String>();
        list.add("1111");
        list.add("2222");

        KindBiz biz = new AKindBiz();
        biz.execute(list);
    }

    public interface KindBiz 
    {
        public void execute( ArrayList<String> inputList) throws Exception;

        public void preExec( ArrayList<String> inputList) throws Exception;
        public void exec( ArrayList<String> inputList) throws Exception;
        public void postExec( ArrayList<String> inputList) throws Exception;
    }

    abstract public class CommonKindBiz implements KindBiz 
    {

        public void execute( ArrayList<String> inputList) throws Exception{
                System.out.println("KindBiz.CommonKindBiz.execute ### inputList1 : " + inputList ); // Nothing printed.

                this.preExec(inputList);
                this.exec(inputList);
                this.postExec(inputList);
        }

        public void preExec( ArrayList<String> inputList) throws Exception
        {    
                System.out.println("KindBiz.CommonKindBiz.preExec ### inputList  : " + inputList );  // Nothing printed.
        }   

        public abstract void exec( ArrayList<String> inputList) throws Exception;

        public void postExec( ArrayList<String> inputList) throws Exception
        {           
                System.out.println("KindBiz.CommonKindBiz.postExec ### inputList : " + inputList );  // Nothing printed.
        }    
    }

    public class AKindBiz extends CommonKindBiz
    {
        @Override
        public void exec( ArrayList<String> inputList) throws Exception
        {           
                System.out.println("KindBiz.AKindBiz.exec ### inputList  : " + inputList ); // "1111", "2222" printed.
        }

    }

}

前もって感謝します。

4

2 に答える 2

0
System.out.prinfln("KindBiz.CommonKindBiz.execute ### inputList1 : " + inputList ); // Nothing printed.  

その行が問題のようです。ですprintln()。コードのどこにでもprinfln(). それらをprintln()

更新:
RC と subash が指摘したように、メソッドは 2 つのパラメーターを取ることを宣言しますが、呼び出すときに 1 つだけを指定します。それらに2を与えるか、メソッドの署名を変更する必要があります。

IDE を使用してください。パラメーターの不一致などのこれらのエラーは、IDE によって非常に簡単に指摘され、何が問題であり、どのように修正するかについての適切な説明が表示されます。

于 2013-11-14T06:52:38.090 に答える
0

コードを編集してコンパイルしました。

テストしたところ、すべての行が印刷されました。問題があるとは思いません。

于 2013-11-14T06:59:17.063 に答える