文字列値をintに変換するには? 私は得てnumber format exception
います。
String s = "20.00";
int i = (Integer.parseInt(s));
System.out.println(i);
結果は次のようになりi=20
ます。
文字列値をintに変換するには? 私は得てnumber format exception
います。
String s = "20.00";
int i = (Integer.parseInt(s));
System.out.println(i);
結果は次のようになりi=20
ます。
String s = "20.00";
is not valid Integer
value that is the reason its throwing NumberFormatException
.
Format your number using either Double
or Float
then using narrow casting cast you number to int
but you may loose precision if exists.
i.e. int I = (int) Double.parseDouble(str);