C:\ece538>java GFG java.lang.NumberFormatException: empty String C:\ece538>java GFG 120 Value = 120.0 C:\ece538>java GFG 10x java.lang.NumberFormatException: For input string: "10x" |
GFG.java
class GFG { public static void main(String[] args) { try { String str = args.length>0? args[0]: ""; // returns the double value // represented by the string argument double val = Double.parseDouble(str); // prints the double value System.out.println("Value = " + val); } catch (Exception e) { System.out.println(e); } } }
Maintained by John Loomis, updated Tue Feb 04 20:07:12 2020