Final keyword java
Hello friends; Hitesh is here today we will learn some basic concept about Final keyword java.
The final keyword in java is used to restrict the user to use some features. In java final keyword can be used in many places;
- A variable level
- At method-level
- At class level
Example of Final keyword in java
class FinalDemo
{
final float PI=3.14159;
void show()
{
System.out.println("Value of PI: "+PI);
}
}
public static void main(String args[])
{
FinalDemo obj=new FinalDemo();
obj.show();
}
}
Output:
Value of PI: 3.14159
No comments:
Post a Comment