当前位置 : 主页 > 编程语言 > c++ >

Java的参数传递

来源:互联网 收集:自由互联 发布时间:2021-06-30
gistfile1.txt import java.util.Arrays;public class Demmo{ private String str="1234"; private char[] chars={'a','b','c'}; public static void main(String[] args){ Demmo demmo=new Demmo(); System.out.println(demmo.str+" "+ Arrays.toString(demm
gistfile1.txt
import java.util.Arrays;
public class Demmo{
    private String str="1234";
    private char[] chars={'a','b','c'};
    public static void main(String[] args){
        Demmo demmo=new Demmo();
        System.out.println(demmo.str+"  "+ Arrays.toString(demmo.chars));
        exchange(demmo.str,demmo.chars);
        System.out.println(demmo.str+"  "+ Arrays.toString(demmo.chars));
    }
    public static void exchange(String str,char[] chars){
        str="5678";
        chars[2]='b';
    }
}
捕获1.PNG
网友评论