当我们声明一个变量 final 并实例化它而不给它一个特定的值时(wuffle)
when we declare a variable final and instantiate it without giving it a specific value(wuffle)
默认值是最终值(wuffle = 0)还是我们可以更改它(wuffle =21)?
class Foof{
final int x=0;
final int wuffle; //IT GETS A DEFAULT VALUE
Foof(){
wuffle = 21; // as it is marked final we should't be able to change its value
}
}
当你声明 final 变量时,它仍然是未定义的。如果你把它定为 final 并且你没有提供定义你的代码将无法编译
默认值是最终值(wuffle = 0)还是我们可以更改它(wuffle =21)?
class Foof{
final int x=0;
final int wuffle; //IT GETS A DEFAULT VALUE
Foof(){
wuffle = 21; // as it is marked final we should't be able to change its value
}
}
当你声明 final 变量时,它仍然是未定义的。如果你把它定为 final 并且你没有提供定义你的代码将无法编译