What does it mean if a class is declared as static? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What does it mean if a class is declared as static?

I know that variables in a class declared as static is to be shared by all instances of that class, but what does it mean when a class is declared as static?

3rd Mar 2020, 12:25 PM
ใ‹ใ‚“ใงใ‚“
ใ‹ใ‚“ใงใ‚“ - avatar
2 Answers
+ 4
imagine a nested classes. class Outer{ class Inner { } } in this case you'll need an instance of Outer to create an instane of Inner. new Outer().new Inner() looks ugly right ? if you declare Inner as static you'll only need the Class just like a static method/variable new Outer.Inner()
3rd Mar 2020, 12:39 PM
Taste
Taste - avatar
0
Taste Ah I see, that makes me more enlightened now. Thank you, very appreciated.
3rd Mar 2020, 12:42 PM
ใ‹ใ‚“ใงใ‚“
ใ‹ใ‚“ใงใ‚“ - avatar