qq_工作_8
2017-06-22 10:25
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[Java] );
}
}
public class HelloWorld { public static void main(String[] args) { // 定义一个长度为5的字符串数组,保存考试科目信息 //String[] subjects = {oracle,php,linux,java,html}; 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[Java] ); //这是第二个问题,数组的访问不是用数组名后根变量的值,而是跟变量的索引位置 System.out.println("数组中第4个科目为:" + subjects[3] ); } }
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = {"oracle","php","linux","java","html"};
System.out.println("数组中第4个科目为:" + subjects[3]);
}
}
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = new String[4];
subjects[0] = "Oracle";
subjects[1] = "PHP";
subjects[2] = "Linux";
subjects[3] = "Java";
System.out.println("数组中第4个科目为:" + subjects[3]);
}
}
Java入门第一季(IDEA工具)升级版
1165547 学习 · 17586 问题
相似问题