Chinaunix首页 | 论坛 | 博客
  • 博客访问: 674647
  • 博文数量: 194
  • 博客积分: 3831
  • 博客等级: 中校
  • 技术积分: 1843
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-28 13:24
文章分类

全部博文(194)

文章存档

2012年(41)

2011年(42)

2010年(45)

2009年(66)

分类: Java

2010-10-18 11:38:44

   JAVA增强型for循环条件使用枚举、数组、和集合类的迭代过程。一下以枚举和一维数组,二维数组为例,对增强型for循环做了一个事例供参考。
public class testfor {
 enum Color {
  red, white, blue
 };
 static int[] a = { 1, 22, 33, 3333 };
 static int[][] b = { { 1, 22, 33, 3333 }, { 23, 42, 22, 2 } };
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  for (Color c : Color.values()) {
   System.out.println("color:" + c + "\t\n");
  }
  for (int aaa : a) {
   System.out.println("int:"+ aaa + "\t\n");
  }
  for (int[] bb : b) {
   for (int bbb : bb) {
    System.out.println("int[][]:" + bbb + "\t\n");
   }
  }
 }
}
阅读(945) | 评论(0) | 转发(0) |
0

上一篇:SQL语句摘录

下一篇:C语言常用排序

给主人留下些什么吧!~~