????????????
public class Test{ public static void main(String[] args){ if(args.length<3){ System.out.println("Usage: java Test \"n1\"\"op\"\"n2\""); System.exit(-1); } try{ double d1 = Double.parseDouble(args[0]); }catch (NumberFormatException n){ System.out.println("error"); } try{ double d2 = Double.parseDouble(args[2]); }catch (NumberFormatException n){ System.out.println("error"); } double d = 0; if(args[1].equals("+")) d = d1+d2; else if(args[1].equals("-")) d = d1-d2; else if(args[1].equals("x")) d = d1*d2; else if(args[1].equals("/")) d = d1/d2; else{ System.out.println("Error operator!"); System.exit(-1); } System.out.println(d); } }
提示找不到d1,d2对象