Tutorial 44

+2 Arnab Banerjee · February 3, 2015
In 44th java tutorial(Beginners) I saw bucky declaring a String variable like this

private final String desc;
private final String year;

Why or for what purpose he has used the keyword final ?? :wassat:

Post a Reply

Replies

Oldest  Newest  Rating
+1 Duba Blaz · February 3, 2015
A final variable can only be initialized once.

This Bucky's video explain final
https://www.thenewboston.com/videos.php?cat=31&video=18013
+1 Branislav Lazic · February 3, 2015
Basically, in this case it's used for declaration of constants. Although I would add static modifier too. Then it would become constant per application instance and not a constant per class instance.
  • 1

Java / Android Development

106,967 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator