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