- package array;
- public class arrayprint {public static void main(String[] args) {
- /**
- * 数组的输出
- */
- String[] temp = { "离离原上草,", "一岁一枯荣", "野火烧不尽,", "春风吹又生" };
- for (int i = 0; i < temp.length; i++) {
- System.out.println(temp[i]);
- }
- System.out.println("==== 使用 foreach 输出 =======");
- for (String x : temp) {
- System.out.println(x);
- }
- }
- }
输出结果
离离原上草,
一岁一枯荣
野火烧不尽,
春风吹又生
==== 使用 foreach 输出 =======
离离原上草,
一岁一枯荣
野火烧不尽,
春风吹又生
来源: http://www.bubuko.com/infodetail-2513992.html