---
title: "What is final variable in java?"  
description: "What is final variable in java?"  
author: "Royce Roy"  
published: 2015-03-31  
updated: 2020-09-20  
canonical: https://www.mindstick.com/interview/2383/what-is-final-variable-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What is final variable in java?

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

## Answers

### Answer by Anonymous User

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


---

Original Source: https://www.mindstick.com/interview/2383/what-is-final-variable-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
