真的真的不知道我哪里錯(cuò)了,
public class HelloWorld {
??? public static void main(String[] args) {
?? ??? ?
?? ??? ?// 定義一個(gè)長度為 3 的字符串?dāng)?shù)組,并賦值初始值
?? ??? ?String[] hobbys = { "sports", "game", "movie" };
?? ??? ?System.out.println("循環(huán)輸出數(shù)組中元素的值:");
?? ??? ?
?? ??? ?// 使用循環(huán)遍歷數(shù)組中的元素
?? ??? ?for(int i=0;i<hobbys.length;i++);{
?? ??? ? System.out.println(hobby[i]);? ?
?? ??? ?}
?? ??? ?
?? ??? ?
?? ??? ?
?? ??? ?
?? ??? ?
?? ??? ?
?? ?}
}
2015-11-26
for(int i=0;i<=hobbys.length-1;i++){
System.out.println(hobbys[i]);
}//你在for循環(huán)里少了hobbys的長度減1和<=,for循環(huán)外面不用分號,還有輸出的時(shí)候你的hobby應(yīng)該是hobbys
2016-01-04
length后多了一個(gè)分號
public class HelloWorld {
??? public static void main(String[] args) {
?? ??? ?
?? ??? ?// 定義一個(gè)長度為 3 的字符串?dāng)?shù)組,并賦值初始值
?? ??? ?String[] hobbys = { "sports", "game", "movie" };
?? ??? ?System.out.println("循環(huán)輸出數(shù)組中元素的值:");
?? ??? ?
?? ??? ?// 使用循環(huán)遍歷數(shù)組中的元素
?? ??? ?for(int i=0;i<hobbys.length;i++);{//length后多了一個(gè)分號
?? ??? ? System.out.println(hobby[i]);? ?
?? ??? ?}? ? ?
?? ?}
}
2015-11-27
多了個(gè)分號,正解
2015-11-19
System.out.println(hobby[i]); ->hobbys
?for(int i=0;i<hobbys.length;i++)? ;?? { ?? //多了個(gè)分號
?? ??? ? System.out.println(hobby[i]);? ?
?? ??? ?}