/** * Returns a new <code>double</code> initialized to the value * represented by the specified <code>String</code>, as performed * by the <code>valueOf</code> method of class * <code>Double</code>. * * @param s the string to be parsed. * @return the <code>double</code> value represented by the string * argument. * @exception NumberFormatException if the string does not contain * a parsable <code>double</code>. * @see java.lang.Double#valueOf(String) * @since 1.2 */ public static double parseDouble(String s) throws NumberFormatException { return FloatingDecimal.readJavaFormatString(s).doubleValue(); }
double n2 = Double.parseDouble(args[2]);
估计八成在这两行出问题了
double n1 = Double.parseDouble(args[0]);
double n2 = Double.parseDouble(args[2]);
这2行之前加上几句
System.out.println(arg[0]);
System.out.println(arg[2]);看看出来的到底是什么,报错的意思是应该是这2个出现了非数字的内容
* Returns a new <code>double</code> initialized to the value
* represented by the specified <code>String</code>, as performed
* by the <code>valueOf</code> method of class
* <code>Double</code>.
*
* @param s the string to be parsed.
* @return the <code>double</code> value represented by the string
* argument.
* @exception NumberFormatException if the string does not contain
* a parsable <code>double</code>.
* @see java.lang.Double#valueOf(String)
* @since 1.2
*/
public static double parseDouble(String s) throws NumberFormatException {
return FloatingDecimal.readJavaFormatString(s).doubleValue();
}
1 * 3 的时候
System.out.println(args[2]);
输出的结果是一个长字符串