Java - (String [] args)数组传递给类main方法

时间:2013-04-27 00:45:39

标签: java arrays

    System.out.println(args[0] == "x");
    System.out.println(args[0].equals("x"));

    String[] name = {"x"};
    System.out.println(name[0] == "x");
    System.out.println(name[0].equals("x"));

    String[] hello = new String[1];
    hello[0] = "x";
    System.out.println(hello[0] == "x");
    System.out.println(hello[0].equals("x"));

结果

false
true
true
true
true
true

当我调用“java classname x”时,为什么第一次测试会导致'false'?

0 个答案:

没有答案