50,545
社区成员
发帖
与我相关
我的任务
分享
fun(const int& i)
{}
class abc
{
int i=0;
}
static void funParameter(final abc i)
{
i.i=999;
}
public static void main(String[] args)
{
abc a = new abc();
funParameter(a);
System.out.print(a.i);
}
i.i=999;//ok
i = new abc()//The final local variable i cannot be assigned. It must be blank and not using a compound assignment
如果参数类型是int,下面的方法会报错
static void funParameter(final int i) {
i = 999;//The final local variable i cannot be assigned. It must be blank and not using a compound assignment
}