java数组复制===clone()

总结:使用方法原理弄清楚

package com.a;

public class gjsopb {

	public static void main(String[] args) {
		int a[] = { 2, 35, 43, 654, 3, 1 };
		int b[] = new int[a.length];
		//clone类型返回的是对象,要强制转换为:int[]
		b = (int[]) a.clone();
		for (int i = 0; i < a.length; i++) {
			System.out.println(b[i]);
		}
	}
}

  

原文地址:https://www.cnblogs.com/langlove/p/3404651.html