public class test {
public static void main(String[] args) {
// TODO Auto-generated method stub
int[] a = {11,1,5,3,32,23};
Arrays.sort(a);
for(int i : a){
System.out.println(i);
}
String str = Arrays.toString(a);
System.out.printf("%s",str);
int[] b = Arrays.copyOfRange(a, 3,4);
for(int i : b){
System.out.printf("%d", i);
}
int index = Arrays.binarySearch(a, 3,4,32);
System.out.printf("%s", index);
int[] c = new int[5];
Arrays.fill(c,4);
System.out.println(Arrays.toString(c));
//---java.lang.System
int[] from = {1,2,53,4,25,16,27,18,9};
int[] to = {1,22,53,4,25,16,2,8,9};
System.arraycopy(from, 0, to, 1, 1);
System.out.println(Arrays.toString(to));
//--
float[][] f = {{1,2,4},{3,1,2},{2,7,5}};
System.out.println(Arrays.deepToString(f));
for(float[] row : f )
for(float col : row)
System.out.println(col);
//---不规则数组
int[][] oods = new int[5][];
for(int i=0;i<5;i++){
oods[i] = new int[i+1];
}
for(int[] row : oods){
for(int col : row){
System.out.print(col+"\t");
}
System.out.println();
}
}
Java 数组方法
最新推荐文章于 2023-03-20 19:34:53 发布