Is not an enclosing class Java

后端 未结 11 2553
轻奢々
轻奢々 2020-11-28 01:41

I\'m trying to make a Tetris game and I\'m getting the compiler error

Shape is not an enclosing class

when I try t

11条回答
  •  萌比男神i
    2020-11-28 02:08

    To achieve the requirement from the question, we can put classes into interface:

    public interface Shapes {
        class AShape{
        }
        class ZShape{
        }
    }
    

    and then use as author tried before:

    public class Test {
        public static void main(String[] args) {
            Shape s = new Shapes.ZShape();
        }
    }
    

    If we looking for the proper "logical" solution, should be used fabric design pattern

提交回复
热议问题