import java.util.Arrays; public class ArrayCopy { public static void main(String args[]) { System.out.printf("Before (original)/t%s%n", Arrays.toString(args)); String copy[] = Arrays.copyOf(args, 4); System.out.printf("Before (copy)/t/t%s%n", Arrays.toString(copy)); copy[0] = "A"; copy[1] = "B"; copy[2] = "C"; copy[3] = "D"; System.out.printf("After (original)/t%s%n", Arrays.toString(args)); System.out.printf("After (copy)/t/t%s%n", Arrays.toString(copy)); } }
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/11042.html