Why can't we declare a classes as static in java?
Answers
Answered by
3
HEY MATE......
HERE IS UR ANSWER......❤❤
Remember you can only declare astatic class inside a top-level class, it is illegal to declare it inside an innerclass. Nested classes (a class within aclass) are the only ones that can be declared static. This is so the parentclass does not have to be instantiated to access the nestedclass.
HOPE IT HELPS YOU AND MARK AS BRAINLIEST.......☺☺
HERE IS UR ANSWER......❤❤
Remember you can only declare astatic class inside a top-level class, it is illegal to declare it inside an innerclass. Nested classes (a class within aclass) are the only ones that can be declared static. This is so the parentclass does not have to be instantiated to access the nestedclass.
HOPE IT HELPS YOU AND MARK AS BRAINLIEST.......☺☺
Answered by
0
Answer:
We can't declare outer (top level) class as static because the static keyword is meant for providing memory and executing logic without creating Objects, a class does not have a value logic directly, so the static keyword is not allowed for outer class.
Similar questions