有什么问题啊?就是reference传递啊

解决方案 »

  1.   

    就让代码来回答你的问题吧
    class  MyClass2
    {
    public static void main(String[] args) 
    {
    System.out.println("Hello World!");
    String a = "A";
    String b = "B";
    MyClass2.swap(a,b);
    System.out.println("a:" + a);
    System.out.println("b:" + b);
    } public static void swap(String x, String y) 

         String  temp = x; 
         x = y; 
         y = temp; 
    } }
      

  2.   

    java里面好像没有什么全局变量?
      

  3.   

    你说的没错准确的说应该是
    member variable
    automatic variable只是我个人习惯用全局变量这种说法而已.