1 copy Array
Array full copy
Array positioning copy
2 Determine if the array is equal (each element corresponds to equality)
3 Mutual transformation of arrays and sets
1 Importjava.util.Arrays;2 Importjava.util.List;3 4 /*5 1 Copy Array6 Array Full copy7 Array Positioning copy8 2 Determine if the array is equal (each element corresponds to equality)9 3 Mutual transformation of arrays and setsTen * */ One A Public classDemo2 { - Public Static voidMain (string[] args) { -Integer[] arr = {1, 2, 3, 4}; the //array copy function (the array to be copied, the new array length after the copy) -integer[] arr2 = arrays.copyof (arr, 4); -SYSTEM.OUT.PRINTLN ("Array after arr2 copy:" +arrays.tostring (ARR2)); - //Locating copies +integer[] Arr3 = Arrays.copyofrange (arr, 1, 3);//copy 1th to third element, left open right closed, that is, the number of copies is 2,3 -SYSTEM.OUT.PRINTLN ("Array after partial copy of ARR3:" +arrays.tostring (ARR3)); + //To determine the equality of arrays ASystem.out.println ("Compare arr and arr2 are the same:" +arrays.equals (arr, arr2)); at //Convert an array to a list collection -list<integer> list =arrays.aslist (arr); -System.out.println ("Elements of the collection:" +list); - - } -}
Operation Result:
Operation of an array of Java