If the class declaration has final, the class cannot be extended. (Cannot create subclass)
If the instance method declaration has final, it cannot be overridden in the subclass.
You can only assign to a final field once. There are two ways to assign to a final instance field.
class Qiita {
final int value = 123;
}
class Qiita {
final int value;
public Qiita() {
this.value = 123;
}
}
There are two ways to assign to a final class field:
class Qiita {
static final int value = 123;
}
class Qiita {
static final int value;
static {
value = 123;
}
}
Can only be assigned once.
Cannot be assigned even once. (Because the value was already assigned when the method was called)