卜问
2018-10-09 15:48
public class HelloWorld {
public static void main(String[] args) {
// 定义一个长度为5的字符串数组,保存考试科目信息
String[] subjects = new String[] {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] );
}
}
String[] subjects=new Steing[]{"Oracle","PHP","Linux","Java","HTML"}
String subjects[] = new String[] {Oracle,PHP,Linux,Java,HTML} ;
应该是这样
楼上说的都对,但是你 {Oracle,PHP,Linux,Java,HTML} 这数组里每个元素要加引号
下面
subjects[0] = "Oracle";
subjects[1] = "PHP";
subjects[2] = "Linux";
subjects[3] = "Java";
subjects[4] = "HTML";
这里都赋值了,
String[] subjects = new String[] {Oracle,PHP,Linux,Java,HTML} 这里就不用赋值了
String[] subjects = new String[5];
Java入门第一季(IDEA工具)升级版
1165172 学习 · 17581 问题
相似问题