A list,
-
The Arrays class, which comes in the java.util package, mainly contains methods for manipulating Arrays.
-
Import java.util.Arrays
-
The common functions of Arrays are static.
Second, the use of
import java.util.Arrays; Public class test {public static void main(String[] args) { // String Arrays.toString(Object[] array) int[] nums = {4, 1, 9, 8, -5}; System.out.println(Arrays.toString(nums)); // [4, 1, 9, 8, -5] // String Arrays.deepToString(Object[] array) int[][] nums = {{4, 1, 9, 8, -5}, {4, 1, 9, 8, -5}}; System.out.println(Arrays.deepToString(nums)); / / [[4, 1, 9, 8, 5], [4, 1, 9, 8, 5]] / / an array in ascending order: // void Arrays.sort(Object[] array) int[] nums = {4, 1, 9, 8, -5}; System.out.println(" Array before :" + array.toString (nums)); [4, 1, 9, 8, -5] Arrays. Sort (nums); System.out.println(" Array after :" + array.toString (nums)); Void Arrays. Sort (Object[] array, array_array, array_array, array_array, array_array, array_array, array_array, array_array, array_array, array_array int from, int to) int[] nums = {4, 1, 9, 8, -5}; System.out.println(" Array before :" + array.toString (nums)); / / before ordering: [4, 1, 9, 8, 5] Arrays. The sort (nums, 0, 4); System.out.println(" Array after :" + array.toString (nums)); Void array. fill(Object[] array, Object Object) int[] nums = {4, 1, 9, 8, - 5}; System.out.println(" Before :" + array.toString (nums)); [4, 1, 9, 8, -5] Arrays. Fill (nums, 2); Println (" After :" + array.toString (nums)); // array.fill (object [] array, array [] array.fill (object [] array, array) int from, int to, Object object) int[] nums = {4, 1, 9, 8, -5}; System.out.println(" Before :" + array.toString (nums)); / / before ordering: [4, 1, 9, 8, 5] Arrays. The fill (nums, 0, 4, 3); Println (" After :" + array.toString (nums)); // Sort :[3, 3, 3, 3, -5]}}Copy the code