简体   繁体   中英

Difference Between final class and static class

I know a java a little bit , have used final and static multiple times , But I am quiet confused here : What is the basic difference between a final class A and a static class B. I know these keywords . Just could not imagine the use of final in a class declaration.

Final class : In simple words is a class that cannot be extended . - It is generally useful for writing classes to be immutable eg String class that is generally done for security

Static class : Static classes can only be used in case of nested classes. - Nested static class doesn't need reference of Outer class but non static nested class needs it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM