zoukankan      html  css  js  c++  java
  • 数组拷贝问题,实际上是指针指向发生变化

    public class Test{
        public static void main(String args[]){
            int[] a= {1,2,3};
            int[] b={4,5,6};
            //输出两个数组
            System.out.print("原数组a:");
            for(int i : a)
            System.out.print(i+" ");
            System.out.println();
            System.out.print("原数组b: ");
            for(int i : b)
            System.out.print(i+" ");
            System.out.println();
            //拷贝数组
            a=b;
            //输出拷贝后的两个数组
            System.out.print("--------数组拷贝---------\n数组a:");
            for(int i : a)
            System.out.print(i+" ");
            System.out.println();
            System.out.print("数组b: ");
            for(int i : b)
            System.out.print(i+" ");
            System.out.println();
            System.out.println("改变数组a[0]的值==9");
            //改变数组a的值
            a[0]=9;
            System.out.println("a[0] : "+a[0]);
            System.out.println("b[0] : "+b[0]);
        }
    }
    /*
        C:\>javac Test.java
        
        C:\>java Test
        原数组a:1 2 3
        原数组b: 4 5 6
        --------数组拷贝---------
        数组a:4 5 6
        数组b: 4 5 6
        改变数组a[0]的值==9
        a[0] : 9
        b[0] : 9
    
    */
  • 相关阅读:
    flask之Blueprint蓝图
    flask之Flask、config配置
    flask之路由route
    flask之request
    flask之response
    pyhton中的深浅copy
    jQuery选择器
    Html常用标签
    python中的字典dict
    python基础知识
  • 原文地址:https://www.cnblogs.com/laoquans/p/2963351.html
Copyright © 2011-2022 走看看