下面列举 小数转百分数有三种方法
double c = (double) 8 / (double) 9;
1,不四舍五入
直接转成字符串截取
System.out.println(String.valueOf(c * 100).substring(0, 5) + "%");
2,四舍五入
2.1
NumberFormat nt = NumberFormat.getPercentInstance();
// 设置百分数精确度2即保留两位小数
nt.setMinimumFractionDigits(2);
String x= nt.format(c)
System.out.println(x);
2.2
String result = String.format("%.4f", c);
System.out.println(result);