Two public classes in one file java

前端 未结 5 742
青春惊慌失措
青春惊慌失措 2020-12-09 17:58

Ok, this might be kiddies question in java. We can\'t define two public classes in one file. But, in one of the examples from the book SCJP study guide, this example was men

5条回答
  •  伪装坚强ぢ
    2020-12-09 18:48

    Well, if one is being so picky: you can have multiple classes defined with a public modifier in the same file, that is, using the static nested(inner) class. like this:

    File -> Test.java

    public class Test {
    
        public static class SomeNestedClass {
    
        }
    
    }
    

提交回复
热议问题