1 import java.sql.SQLOutput; 2 import java.util.Arrays; 3 import java.util.Scanner; 4 //Arrays类 5 public class test { 6 public static void main(String[] args) { 7 int[] a = {5,4,6,8,9,1,7,2,3} ; 8 //打印数组元素 9 Arrays.toString(a); 10 System.out.println(Arrays.toString(a)); 11 12 Arrays.sort(a);//对数组进行升序排序 13 System.out.println(Arrays.toString(a)); 14 15 int index = Arrays.binarySearch(a,5);//二分查找 16 System.out.println("index = "+index); 17 18 Arrays.fill(a,2,4,0);//数组的填充(2-4之间的元素被填充) 19 System.out.println(Arrays.toString(a)); 20 21 } 22 }
标签:index,Arrays,18,System,toString,println,2023.7,out From: https://www.cnblogs.com/muzhaodi/p/17564189.html