Hi! I've got a big problem...
I try to get a decimal number from a String...
For that I've used this Method:If I insert "212" There's no problem and it returns 212.0.
But If it try "212.2" I got this message:
java.lang.NumberFormatException: For input string: "212.2"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:458)
at java.lang.Integer.<init>(Integer.java:660)
at Numbers.getDouble(Numbers.java:13)
at __SHELL9.run(__SHELL9.java:7)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at greenfoot.localdebugger.LocalDebugger$QueuedExecution.run(LocalDebugger.java:260)
at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:406)
at greenfoot.core.Simulation.maybePause(Simulation.java:318)
at greenfoot.core.Simulation.runContent(Simulation.java:194)
at greenfoot.core.Simulation.run(Simulation.java:187)
What's wrong? Can anyone help me, plz.
public static double getDouble(String ndouble) { Integer i = new Integer(ndouble); double d; try { d = i.doubleValue(); } catch(Exception e) { return 0; } return d; }