Exception in thread "main"
package com.lianxi;
public class jv65 {
public static void main(String[] args) {
// 定义一个长度为 3 的字符串数组,并赋值初始值
String[] hobbys = { "sports", "game", "movie" };
System.out.println("循环输出数组中元素的值:");
for(int i=0;i<=hobbys.length;i++){
System.out.println(hobbys[i]);
// 使用循环遍历数组中的元素
}
}
}
循环输出数组中元素的值:
sports
game
movie
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at com.lianxi.jv65.main(jv65.java:10)