Abhishek Bhandari
Abhishek Bhandari

Reputation: 623

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.

Upvotes: 4

Views: 7231

Answers (1)

Harpreet Singh
Harpreet Singh

Reputation: 656

Final class : In simple words is a class that cannot be extended . - It is generally useful for writing classes to be immutable e.g. 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

Upvotes: 9

Related Questions