本帖最后由 郭永岳 于 2012-6-5 19:36 编辑
田建 发表于 2012-6-5 10:19 ![]()
我写了一个代码,将这稍微实现了下,你看下!我是菜鸟,写的烂请勿介意!! ... 20行和22行不太明白呢,可以给我讲讲吗?
我在你看看我注释得对不对咯。- class MyselfTest8
-
- {
-
- public static void main(String[] args)
-
- {
-
- double dou=199.999;
-
- subDou(dou);
-
-
- }
-
- public static void subDou(double dou)
-
- {
-
- String s=String.valueOf(dou); <font color="red">//请问这里是不是把double型的dou转成字符型?
- </font>
- int index=s.indexOf('.'); <font color="red">//这里的indexOf不太明白??
- </font>
- s=s.substring(0,index+2);
-
- System.out.println(s);
-
- s=s.replace('.',',');
-
- System.out.println(s);
-
-
- }
-
- }
复制代码 |