• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

final local class  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the modifier final can be applied to a local class..that means a final local class cannot have subclasses...does it mean that if the modifier final is not applied, u can extend the local class?....but the local class is local to the block in which it is created and cant be accessed outside that block...isn't it contradictory?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try it? Here's an example of a non-final local class being extended:


[ August 26, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that your reffering to inner classes, they can be extened inside the outer class.
 
Sandya Bhaskara
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx barry..i didn't get that idea....extending local class in the block in which it is declared....thanx a lot for the example too...but can u extend a local class outside the block in which it is declared?

hi benjamin..i wasn't refering to an inner class...inner classes can be extended even outside the class in which they r declared
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but can u extend a local class outside the block in which it is declared?




Best left as an exercise for the student... Write some code to test the hypothesis.
 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If your definition of local class is a class declared inside a method; and you want to extend that "local" class "out side" the method, i don't think it is possible, since by the very definition of "local variables" the scope is limited to that block/method and convetionally all the local variables are destroyed once the method exists. The very reason of decalring them final is to extend their life times.

I hope i got your question right and this helps.

thanks
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!