If I set a value of an attribute of a class and use final, do i have to initialise the attribute as a parameter of the class constructor? For example, I have set the attribute rack of length to a value of 60
public class Runs {
Teams team;
final int racklength=60;
int xposteam;
public Runs (Teams y) {
team=y;
}
}
You must always initialize a
finalattribute, but you can do it either in-place (where you first declare it) or in its constructor (or constructors):