• Post Reply Bookmark Topic Watch Topic
  • New Topic

final class  RSS feed

 
bakiyalakshmi dhanraj
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a class is declare as a final? what is the use? don't tel it cannot be override... i need some other answer....please tel me

thanks
bakiya
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bakiyalakshmi dhanraj:
If a class is declare as a final? what is the use? don't tel it cannot be override... i need some other answer....please tel me

Well if I can't tell you it is to make sure the class cannot be overridden (actually extended), I cannot give you an answer, because that IS the answer. The final keyword means just that for classes: no subclasses are allowed.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the definition of a class is complete and you do not want it to be subclassed, then you can declare it final. As subclassing is not possible, then the methods of a final class are implicitly final and can therefore never be overridden.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bakiyalakshmi dhanraj:
If a class is declare as a final? what is the use? don't tel it cannot be override... i need some other answer....please tel me


You need another answer, apart from the correct answer? You want us to start making up wrong answers?!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!