日期:2014-05-20  浏览次数:20745 次

大家帮我看看这段代码为什么错误呢?
package ch7;

public class FinalExample {

/**
* @param args
*/
static final int i;


public static final int total=10;

public FinalExample (int i){
this.i=1;

}
public static void main(String[] args) {
// TODO Auto-generated method stub
FinalExample example =new FinalExample(1);
example.i=10;

}

}


显示说因为final错误,但是感觉没有错误压


------解决方案--------------------
当然有错啊,final修饰变量 ,表示这个变量一旦被初始化便不可改变,相当于常量了。