I am working on a project that requires me to parse a String into an Integer. I have not had this problem before, but when I try to parse a String to an Integer, I get this message
Exception in thread "main" java.lang.NumberFormatException: For input string: "385.3100"
, where 385.3100 is the integer in question. Nothing I have done is working.
String close = (closing.get("4. close").toString()); int money = Integer.parseInt(close);
Is my code, where closing is a JSONObject.
Any help would be appreciated!
385.3100 is not an integer but a number with decimal precision. Use:
Double.parseDouble()
or Float.parseFloat()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.