Java: A Puzzle about Constructor…

package cn.com.sina.blog.chanryma.interf;

public interface IAction {
    void walk();
}

package cn.com.sina.blog.chanryma.impl;

import cn.com.sina.blog.chanryma.interf.IAction;

 

public class Human {
    protected class NewBeing implements IAction {
        @Override
        public void walk() {
            System.out.println("Walk and walk...");
        }
    }
}

Java: <wbr>A <wbr>Puzzle <wbr>about <wbr>Constructor <wbr>of <wbr>Inner <wbr>Class

Because of NewBeing is protected, there is an error. To remove it, NewBeing needs to be public or a public constructor for NewBeing is required.

 

你可能感兴趣的:(Java: A Puzzle about Constructor…)