直接改变float变量的精度  是不可能了。。
你可以 扩大十倍,再四舍五入阿 最后缩小10倍,

解决方案 »

  1.   

    j2se 1.5.0有printf可以很容易做到,以前版本实现起来比较麻烦。试试这样:float f=3.1415926;f = ((float)((int)(f*10.0)))/10.0
      

  2.   

    用专门格式化的类,在java.text包下,好象是NumberFormat之类的.
      

  3.   

    The JavaTM Tutorial
    Customizing Formats
     
    http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html
      

  4.   

    package test;import java.text.*;public class Test {

    public static void main(String[] args) {
            float[] float_args = {12345.26f, 1234.22f, 123.22f, 0.123456789f};
            for (int i = 0; i < float_args.length; i++) {
    System.out.println(floatFormat(float_args[i]));
    }
    }

    public static String floatFormat(float f) {
    DecimalFormat df = new DecimalFormat("0.#");
            return df.format(f);        
    }
    }
      

  5.   

    用 java.util.DecimalFormat 可以做到的。