QuesHub > 声明 > 嵌套 > 静态 > ASK DETAIL

Can we have a static class in Java?

Ryan Gonzalez | 2023-05-05 14:10:00 | page views:1092
I'll answer
Earn 20 gold coins for an accepted answer.20 Earn 20 gold coins for an accepted answer.
40more

Charlotte White

Studied at University of Oxford, Lives in Oxford, UK
But remember you can only declare a static class inside a top-level class, it is illegal to declare it inside an inner class. Nested classes (a class within a class) are the only ones that can be declared static. This is so the parent class does not have to be instantiated to access the nested class.
2023-05-15 14:10:00

Noah Garcia

QuesHub.com delivers expert answers and knowledge to you.
But remember you can only declare a static class inside a top-level class, it is illegal to declare it inside an inner class. Nested classes (a class within a class) are the only ones that can be declared static. This is so the parent class does not have to be instantiated to access the nested class.
ask:3,asku:1,askr:137,askz:21,askd:152,RedisW:0askR:3,askD:0 mz:hit,askU:0,askT:0askA:4