转int啥啥啥的

1、String转int类型的话。需要用Double.valueof("这写String类型的数据").intValue();

2、保留小数点:

  

float scale = (float) 100;

DecimalFormat fnum = new DecimalFormat("0.00");

String dd=fnum.format(scale/100);

System.out.println(dd);

float f = Float.parseFloat(dd);

System.out.println(f);

结果:

  1.00

  1.0

注意:DecimalFormat的方法format中需要有其中一个数是float类型的数值

3、比较String类型用equals 数值可以用==

猜你喜欢

转载自www.cnblogs.com/LambertL/p/10532607.html
今日推荐