float num= (float)2/3;
NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
//最后格式化并输出
System.out.println("百分数:" + nt.format(num));
float num= (float)2/3;
NumberFormat nt = NumberFormat.getPercentInstance();
//设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
//最后格式化并输出
System.out.println("百分数:" + nt.format(num));