• Post Reply Bookmark Topic Watch Topic
  • New Topic

final keyword  RSS feed

 
Swapna Mandava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one explain me the use of 'final' variable?
eg: final int i=10;

What is the role of the keyword 'final'?

Also if I declare,
final Vector v v= new Vector(10);

Can I add elements to Vector now after declaring it with 'final'?

Thanks in advance,
Swapna
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swapna,
"final" means that the variable reference cannot be changed. This means I cannot do:


You can call methods on a final variable which means this is allowed:
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!