+ 3

When we use final variables?what is the purpose?

1st May 2018, 12:18 PM
Mohammed Sabiq
Mohammed Sabiq - avatar
6 Respostas
+ 6
In Java you declare a variable final to prevent it from being modified... If you do not want your variable to ever be changed you declare it final and that way you make it a constant.
1st May 2018, 12:23 PM
cyk
cyk - avatar
+ 2
Sure! Look at this code and read the comments. Let me know if you need more explaining ☺ https://code.sololearn.com/calOxXDS1Q6T/?ref=app
2nd May 2018, 2:28 AM
cyk
cyk - avatar
+ 1
thnx
1st May 2018, 2:00 PM
Mohammed Sabiq
Mohammed Sabiq - avatar
0
can u explain with examples.
2nd May 2018, 2:09 AM
Mohammed Sabiq
Mohammed Sabiq - avatar
0
great.
2nd May 2018, 4:27 AM
Mohammed Sabiq
Mohammed Sabiq - avatar
0
if you use final keywords to create a variable it means u can't change the value of that variable
2nd May 2018, 12:46 PM
SAURAV KUMAR
SAURAV KUMAR - avatar