NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` // "static void main" must be defined in a public class. public class Main { public static void main(String[] args) { // 1. Initialize int[] a0 = new int[5]; int[] a1 = {1, 2, 3}; // 2. Get Length System.out.println("The size of a1 is: " + a1.length); // 3. Access Element System.out.println("The first element is: " + a1[0]); // 4. Iterate all Elements System.out.print("[Version 1] The contents of a1 are:"); for (int i = 0; i < a1.length; ++i) { System.out.print(" " + a1[i]); } System.out.println(); System.out.print("[Version 2] The contents of a1 are:"); for (int item: a1) { System.out.print(" " + item); } System.out.println(); // 5. Modify Element a1[0] = 4; // 6. Sort Arrays.sort(a1); } } ```