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

来源:10-7 UML 简介

ruyi8806

2016-05-19 09:21

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();

}

     }

  


写回答 关注

2回答

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

    可以的哦!

    ruyi88...

    谢谢!

    2016-05-19 09:49:01

    共 1 条回复 >

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

    可以的

    ruyi88...

    谢谢!

    2016-05-19 09:50:38

    共 1 条回复 >

Java入门第二季 升级版

课程升级!以终为始告别枯燥,在开发和重构中体会Java面向对象编程的奥妙

530680 学习 · 6091 问题

查看课程

相似问题