[英]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 . 我知道一点java,多次使用final和static,但我在这里很安静:最终的A类和静态类B之间的基本区别是什么。我知道这些关键字。 Just could not imagine the use of final in a class declaration. 无法想象在类声明中使用final。
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 - 将类编写为不可变通常很有用,例如通常为安全性而完成的String类
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 - 嵌套静态类不需要引用外部类,但非静态嵌套类需要它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.