我编程时编入一句:System.out.printf("%10.2f",b);
后来编译的时候系统提示说:The method printf(String,Object[])in the type PrintStream is not applicable for the arguments(String,double).
不知道应该怎么改动,大家帮忙一下!

解决方案 »

  1.   

    我试了一下,好像没有你说的这个问题吗。
    public class test {
      public test() {
      }  public static void main(String[] args) {
        double b=1.01;
        String a="%10.2f";
        System.out.printf(a,b);
      }
    }
      

  2.   

    更新eclipse版本到3.1以上jdk为1.5以上
      

  3.   

    如果版本没问题,
    project按右键->Properties->compiler 
    把编译调成5.0而非1.4 or 1.3 
      

  4.   

    查看一下你当前JDK版本的API文档就知道了。
      

  5.   

    我的eclipse是3.1版本的,是不是版本不够呢?
      

  6.   

    我已经按照你说的把编译调成5.0,以前那个问题没有了,但是又出现了新问题:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6
    at Ha.main(Ha.java:20)
      

  7.   

    我虽然不知道你的程序是这么样的 但是我猜
    你的错误应该是 你所用的量出了错误
    The method printf(String,Object[])
    是说打印String类型的Objectin 
    the type PrintStream is not applicable for the arguments(String,double).
    我也只能看个大概 
    好像是说没有找到,double可以这么说 你需要改下你量
    double类型或String类型有错误
      

  8.   

    需要数组, 填入数值当然不行拉
    System.out.printf("%10.2f",new Object[]{new Double(0.1)});