为什么这样不行?
public class HelloWorld {
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = {Oracle,PHP,Linux,Java,HTML};
System.out.println("数组中第4个科目为:" +subjects[3]);
}
}
public class HelloWorld {
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = {Oracle,PHP,Linux,Java,HTML};
System.out.println("数组中第4个科目为:" +subjects[3]);
}
}
2015-07-26
public class HelloWorld {
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = {"Oracle","PHP","Linux","Java","HTML"} ;
// 分别为数组中的元素赋值
subjects[0] = "Oracle";
subjects[1] = "PHP";
subjects[2] = "Linux";
subjects[3] = "Java";
subjects[4] = "HTML";
System.out.println("数组中第4个科目为:" + subjects[3] );
}
}
举报