error: cannot find symbol
System.out.println(hobbys[i]);
^
symbol: variable i
location: class HelloWorld
1 error
楼上正解。
你的代码相当于:
for(int i=0;i<hobbys.length;i++){
//什么都不干
}
System.out.println(hobbys[i]);//此处会报错,变量i没有定义
for(int i=0;i<hobbys.length;i++);{
这里多了个分号,把;去掉即可。if()后面不需要加;
for(int i=0;i<hobbys.length;i++){