Java中的DecimalFormat(“ 000000E0”)
DecimalFormat是NumberFormat的一个具体子类,用于格式化十进制数字。让我们设置DecimalFormat(“000000E0”)并使用该format()方法。
new DecimalFormat("000000E0").format(199)
new DecimalFormat("000000E0").format(29089)由于我们在Java中使用了DecimalFormat类,因此必须导入以下包-
import java.text.DecimalFormat;
以下是完整的示例-
示例
import java.text.DecimalFormat;
public class Demo {
public static void main(String[] argv) throws Exception {
System.out.println(new DecimalFormat("000000E0").format(199));
System.out.println(new DecimalFormat("000000E0").format(29089));
System.out.println(new DecimalFormat("000000E0").format(398987));
System.out.println(new DecimalFormat("000000E0").format(498989));
System.out.println(new DecimalFormat("000000E0").format(6989898));
System.out.println(new DecimalFormat("000000E0").format(7688888));
}
}输出结果
199000E-3 290890E-1 398987E0 498989E0 698990E1 768889E1
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短