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.
Asked
Active
Viewed 6,534 times
4
-
2What parts of their definition are you having trouble understanding? – Thihara Sep 25 '13 at 12:06
-
1http://stackoverflow.com/questions/5181578/use-of-final-class-in-java – assylias Sep 25 '13 at 12:07
-
1http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class – assylias Sep 25 '13 at 12:08
-
3Oops.. looks like someone is doing the googling for you... – Marko Topolnik Sep 25 '13 at 12:08
-
Thanks ! the above linked made it clear simple enough .I scrolled down the scroll bar and found nothing duplicating while posting this QA .thanks for bearing it :). – Abhishek Bhandari Sep 25 '13 at 12:15
-
The difference is that they are not the same. If you don't understand what 'static' or 'final' mean, just say so, or better still look them up. – user207421 Sep 25 '13 at 12:18
-
@EJP final in a variable fixes its value , final in a method does not allow it to be overloading . their is a significant difference of its characteristic depending on where it is being used . I never had the case where I create a final class.So lacked some practice may be – Abhishek Bhandari Sep 25 '13 at 12:23
-
I know what 'final' means. The problem here is actually that *you* don't. That's the real question. Not 'what is the difference ...'. – user207421 Sep 25 '13 at 12:26
1 Answers
8
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

Harpreet Singh
- 647
- 10
- 24