java 将 Double类型的数据转换为Int 类型 四舍五入

来源:互联网 发布:亚马逊a9算法基本因素 编辑:程序博客网 时间:2024/05/17 17:59
package util;import java.text.DecimalFormat;public class test {public static void main(String[] args) {DecimalFormat df = new DecimalFormat("######0"); //四色五入转换成整数Double x=3.14159;Double y=3.64521;System.out.println(df.format(x));System.out.println(df.format(y));}}

0 0
原创粉丝点击