【java】java.util.Arrays类常用方法

时间:2023-01-18 19:39:20
【java】java.util.Arrays类常用方法【java】java.util.Arrays类常用方法
 1 package Arrays类;
 2 
 3 import java.util.Arrays;
 4 
 5 public class TestArrays {
 6     public static void main(String[] args) {
 7         int[] a={1,9,3,5,7,8,2,6,0,4};
 8         System.out.println(Arrays.binarySearch(a, 9));//-11
 9         Arrays.sort(a);
10         System.out.println(Arrays.binarySearch(a, 9));//9
11         int[] b=new int[9];
12         Arrays.fill(b, 8);
13         System.out.println(Arrays.toString(b));//[8, 8, 8, 8, 8, 8, 8, 8, 8]
14     }
15 }
View Code