Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone give an example of 'final' keyword?
Posted
Updated 14-Feb-10 1:28am
v3

1 solution

on a class, it prevents sub classing
on a field, it prevents instantiation without initializing the field
on a local variable, it declares it to be constant
Java
class clsfinal
{
public static void main(String[] arrValues)
{
  final int PI = 3.14;
}
}

so here you can't modify the value of the variable PI.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900