问答详情
源自:10-7 UML 简介

内部类可以用public修饰吗?下面代码报错

package fgdg;

     public interface Shape {

public void paint();

     }

    public class Painter {

     

        private class InnerShape implements Shape{

public void paint(){

System.out.println("painter paint() method");

}

}

public Shape getShape(){

return new InnerShape();

}   

     

        public static void main(String []args){

Painter painter = new Painter();

Shape shape = painter. getShape();

shape.paint();

}

     }

  


提问者:ruyi8806 2016-05-19 09:21

个回答

  • sophiename
    2016-05-19 09:33:27
    已采纳

    可以的哦!

  • weichenhui
    2016-05-19 09:47:26

    可以的