• Post Reply Bookmark Topic Watch Topic
  • New Topic

access modifier in loal variables

 
Debashree Halder
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why only 'final' be applied as access modifier in local variables? What is wrong with public,private and protected.

Regards,
Debashree Halder
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because no need for other.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The final modifier is a non-access modifier which can b applied to class,method r variable..the local variable has the scope of only the method itself ...so there is no need for access modifiers like public,private r protected ....

thanks & regards
srikanth
 
Arulkumar Gopalan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because, purpose of final is to declare constant variables.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!