以下实例演示了如何通过循环输出数组:
Welcome.java 文件
public class Welcome {
public static void main(String[] args){
String[] runoobs = new String[3];
runoobs[0] = “菜鸟教程”;
runoobs[1] = “菜鸟工具”;
runoobs[2] = “菜鸟笔记”;
for (int i = 0; i < runoobs.length; i++){
System.out.println(runoobs[i]);
}
}
}
以上代码运行输出结果为:
菜鸟教程
菜鸟工具
菜鸟笔记