public class SimpleArray2 {
    public static void main(String[] args) {
        int score[] = new int[] {90, 85, 55, 94, 77};
 
        for(int i = 0; i < score.length; i++) 
            System.out.printf("score[%d] = %d\n", i, score[i]); 
    }
}例如System.out.printf("score[%d] = %d\n", i, score[i]); 里面的printf会报错说“方法不使用”
请问怎么解决?我的是jdk1.6的

解决方案 »

  1.   

    可能是你项目的JDK没有指定为JDK1.6,又或者项目属性中“Java Compiler”中指定的Compiler compliance level没有指定为6.0
      

  2.   

    同意楼上的,在 Window --> Preferences... --> Java --> Compiler 的 Compiler compliance level 改为 6.0 的就可以了。
      

  3.   

    JDK1.5就可以这么用了啊,难道6不可以了吗?
      

  4.   

    6 也可以啊,只不过可能在 Eclipse 设置的编译级别变成了 1.4 的缘故吧。