If you make any variable as final, you cannot change the value of final variable(It will be constant).
There is a final variable speedlimit, we are going to change the value of this variable, but It can't be changed because final variable once assigned a value can never be changed.
class Bike9{ final int speedlimit=90;//final variable void run(){ speedlimit=400; } public static void main(String args[]){ Bike9 obj=new Bike9(); obj.run(); } }//end of class
Output:Compile Time Error
Liked By
Write Answer
What is final variable in java?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
31-Mar-2015Output:Compile Time Error