Java中的DecimalFormat(“ 000E00”)
DecimalFormat是NumberFormat的一个具体子类,用于格式化十进制数字。
让我们首先设置DecimalFormat(“000E00”)-
Format f = new DecimalFormat("000E00");现在,我们将格式化数字并使用format()方法将结果显示为字符串-
String res = f.format(-5977.3427);
由于我们在Java中同时使用了Format和DecimalFormat类,因此必须将以下软件包导入-
import java.text.DecimalFormat; import java.text.Format;
以下是一个例子-
示例
import java.text.DecimalFormat;
import java.text.Format;
public class Demo {
public static void main(String[] argv) throws Exception {
Format f = new DecimalFormat("000E00");
String res = f.format(-5977.3427);
System.out.println(res);
}
}输出结果
-598E01
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短