Wednesday 20 January 2016

Final keyword in Java

Final keyword in Java

Final keyword in java is used for mainly three purpose; Here i will discuss in short about these things.

Final Keyword


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 area
{
 public static final PI=3.141;
 public static void main(String arg[])
 {
  System.out.println(PI);
 }
}
In short you can say that final keyword is used at three level in java program.

  • 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