public class HelloWorld {
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = new int[5] ;
// 分别为数组中的元素赋值
subjects[0] = "5";
subjects[1] = "6";
subjects[2] = "4";
subjects[3] = "2";
subjects[4] = "8";
System.out.println("数组中第4个科目为:" + subjects[2] );
}
}
数据类型要对应
搜索
复制
String[] subjects =new String[5];