对double类型的数取两位小数

import java.text.NumberFormat;
public class test {
 public static void main(String args[]) {
  double votevs = 6.8/2.3;
    NumberFormat formatter = NumberFormat.getNumberInstance();
    formatter.setMaximumFractionDigits(2);
    String vs = formatter.format(votevs);
    System.out.println(votevs);
    System.out.println(vs);

 }

}

你可能感兴趣的:(String,Class,import)