Final keyword in Java
Final keyword in java is used for mainly three purpose; Here i will discuss in short about these things.First final keyword in java are used for make variable as constant. Second is used for restrict method overriding, And third use of final keyword is restrict inheritance in program. It means you can't inherit base class properties into derived class.
Syntax for final keyword at variable level
public class areaIn short you can say that final keyword is used at three level in java program.
{
public static final PI=3.141;
public static void main(String arg[])
{
System.out.println(PI);
}
}
- At variable level
- At class level
- At method level
I hope this article is helpful for you, for more detail you can visit our website, There i will give you all tutorial in detail.
No comments:
Post a Comment