简体   繁体   中英

Exception in thread “main” java.lang.NumberFormatException: For input string

I am using the Netbeans IDE for my code. I am getting this error when I try to run it:"

Exception in thread "main" java.lang.NumberFormatException: For input string: "8589.416,5468.2407,4263.4077,4064.9358,1997.893,5282.325,2169.72,2773.4211,7526.386,4607.6763,2598.06,1522.6462,1300.5988,1181.63,Tumor"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1250)
    at java.lang.Double.parseDouble(Double.java:540)
    at Preprocessing.Newsvm_scale.run(Newsvm_scale.java.java:150)
    at Preprocessing.Newsvm_scale.main(Newsvm_scale.java.java:332)

I keep in mind that the other similar questions here couldn't helped me since I have a different code. My code is below. If anyone can point me in the right direction I will be incredibly grateful. Thanks.

The StringTokenizer method has set one long string to the value st, which is not being broken up. So when the Double Parse method is being called. It throws a Number format exception, because it is trying to convert that string to a double. You need to specify that commas separate the numbers when calling the StringTokenizer method. Feel free to ask if you like some more assistance.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM