1,292   Java

字符串转整形,一般使用

String s="123";
int n=Integer.parseInt(s);

如果字符串包含小数点,则使用

String s="12.3";
int n = (int) Double.parseDouble(s)



Leave a Reply

Your email address will not be published. Required fields are marked *