首页 > 试题广场 >

What will be the ...

[不定项选择题]
What will be the output when executing this main? (单选)

public class Test {
    public static void swapStrings(String x, String y) {
        String temp = x;
        x = y;
        y = temp;
    }

    public static void main(String[] args) {
        String a = "1";
        String b = "2";
        swapStrings(a, b);
        System.out.println("a=" + a + " ,b=" + b);
    }
}
  • An exception will be thrown
  • “a=2 ,b=1”
  • “a=1 ,b=2”

这道题你会答吗?花几分钟告诉大家答案吧!