public class HelloWorld { public static void main(String[] args) { // 定义一个长度为5的字符串数组,保存考试科目信息 String[] subjects =new int[5] ; // 分别为数组中的元素赋值 subjects[0] = "Oracle"; subjects[1] = "PHP"; subjects[2] = "Linux"; subjects[3] = "Java"; subjects[4] = "HTML"; System.out.println("数组中第4个科目为:" + subjects[3] ); } }
String[] subjects =new int[5] ;这个地方错了。应该改成String[] subjects=new String[5]。前面是什么数据类型后面就是什么数据类型
醉了,人家的是字符串
Srring[] subjects=new String[5];
String[] subjects = new String[5];
改成这样:
String[] subjects =new String[5] ;
String[] subjects = new string [5];数组类型!!!!你到底是要String类型还是int类型啊????