• JavaSE 面试题: 方法的参数传递机制


    JavaSE 面试题 方法的参数传递机制

    import java.util.Arrays;
    
    public class Test {
        public static void main(String[] args) {
            int i = 1;
            String str = "hello";
            Integer num = 200;
            int[] arr = {1, 2, 3, 4, 5};
            MyData my = new MyData();
    
            change(i, str, num, arr, my);
    
            System.out.println("i = " + i);
            System.out.println("str = " + str);
            System.out.println("num = " + num);
            System.out.println("arr = " + Arrays.toString(arr));
            System.out.println("my.a = " + my.a);
        }
    
        public static void change(int j, String s, Integer n, int[] a, MyData m) {
            j += 1;
            s += "world";
            n += 1;
            a[0] += 1;
            m.a += 1;
        }
    }
    
    class MyData {
        int a = 10;
    }
    

    参考答案

    ``` i = 1 str = hello num = 200 arr = [2, 2, 3, 4, 5] my.a = 11 ```
  • 相关阅读:
    乱七八糟的
    C# 获取客户端电脑MAC 地址
    CheckInput
    gridview 合计行实现
    乱七八糟22
    jQuery UI CSS Framework
    CSS float和CSS clear
    smtp,POP3,IMAP
    960GridSystem
    CSS 清除浮动
  • 原文地址:https://www.cnblogs.com/hgnulb/p/11380215.html
Copyright © 2020-2023  润新知