Random 隨機數
數組
靜態初始化數組
數組在計算機中的基本原理
數組的訪問
什么是遍歷
數組的動態初始化
動態初始化數組元素默認值規則
Java內存分配介紹
數組在計算機中的執行原理
使用數組時常見的一個問題
案例求數組元素最大值
public class Test1 {public static void main(String[] args) {int[] sources = {90, 50, 20, 10, 100,-5};int max = sources[0];for (int i = 1; i < sources.length; i++) {if (sources[i] > max) {max = sources[i];}}System.out.println("最大值是" + max);}
}
案例數組反轉
public class Test2 {public static void main(String[] args) {//數組反轉int[] arr = {50, 40, 30, 20, 10};for (int i = 0, j = arr.length - 1; i < j; i++, j--) {int temp= arr[j];arr[j] = arr[i];arr[i] = temp;}System.out.println(arr[0]);System.out.println(arr[1]);System.out.println(arr[2]);System.out.println(arr[3]);System.out.println(arr[4]);}
}