package com.zx.test; public class CloneTest { public static void main(String[] args) { int[] luckyNumbers = {2, 3,5,7,9}; int[] cloned =luckyNumbers.clone(); cloned[1] = 15; for (int i = 0; i < cloned.length; i++) { System.out.print(cloned[i]); System.out.print(","); } System.out.println(); for (int i = 0; i < luckyNumbers.length; i++) { System.out.print(luckyNumbers[i]); System.out.print(","); } } } 結(jié)果: 2,15,5,7,9, 2,3,5,7,9, |
|