zoukankan      html  css  js  c++  java
  • String作为函数参数时,传入的是值,不是地址

    写个小程序试下:

    public class Example {

        String str = new String("good");

        char[] ch = { 'a', 'b', 'c' };

        public static void main(String args[]) {

            Example ex = new Example();

            ex.change(ex.str, ex.ch);

            System.out.print(ex.str + " and ");

            System.out.print(ex.ch);

        }

        public void change(String str, char ch[]) {

            System.out.println("str:"+str+", ch:"+ch);
            str = "test ok";

            ch[0] = 'g';

        }
    }

    运行结果:

    str:good, ch:[C@de6ced
    good and gbc

  • 相关阅读:
    k邻近
    C语言实现pwd—关于linux文件系统
    Linux多线程
    有关临时表
    毕设—线程池thread_pool(草)
    3-26
    3-25
    3-22
    关于中国神华
    3-20
  • 原文地址:https://www.cnblogs.com/lan-writenbook/p/5427320.html
Copyright © 2011-2022 走看看