Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic