double d = 1234567.01;
    DecimalFormat df = new DecimalFormat("#,###,###.##");
    String str1 = df.format(d);
    System.out.println(str1);这样可以吗?

解决方案 »

  1.   

    可是这些数字是在一个串里的,串的内容是变化的,该怎么办呢?比如String money,里面是一串数。
      

  2.   

    自己写个方法吧:
    String format(String s)
    {
        int index=s.lastIndexOf(".");
        if(index<0) index=s.length();
        for(int i=index;i>3;i-=3)
        {
          s=s.substring(0,i-3)+","+s.substring(i-3,s.length());
        }
        return s;
     }
      

  3.   

    import java.text.NumberFormat;
    import java.util.Locale;
    public class DD {
    public static void main(String args[]) {
    double d=1234567.01;
    // 得到本地的缺省格式
    NumberFormat nf1 = NumberFormat.getInstance();
    System.out.println(nf1.format(d));
    }
    }
    这个怎么样啊,你想得到别国的形式都可以NumberFormat.getInstance();
      

  4.   

    kypfos(深圳不是我的家) 的方法是比较简便的。
    如果想试试手,可以自己写一个方法,实现,用while吧,我用c写过
      

  5.   

    对,用kypfos的方法,很不错,
      

  6.   

    scbb(星际Baby) , kypfos(深圳不是我的家)  Are right !