Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

local variable

 
rengarajan vaikuntam
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we say a variable declared inside a try block as a local variable?

Pls can someone explain.
Thanks.
 
Mikalai Zaikin
Ranch Hand
Posts: 3330
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Variables can be:

1. "class variable" - static variable declared in class scope, holds same value for all instances of the class
2. "instance variable" - variable declared in class scope and holds value unique to each instance.
3. "local variables" - variable declared inside method or any other block which defines (limits) visibility, like : a) method b) "for" loop declaration c) "catch" clause, etc ...

So, basically, you are right, and variable inside "try" block considered local variable.

regards,
MZ
 
rengarajan vaikuntam
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mikalai Zaikin
I have one more doubt
can we say, a class, whose constructors are all marked private, a final class.
Thamks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rengarajan vaikuntam:
Thanks Mikalai Zaikin
I have one more doubt
can we say, a class, whose constructors are all marked private, a final class.
Thamks


A class with only private constructors is implicitly final. As far as I know, such a class can not be successfully extended.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic