AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
``` // "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); } } ```