题目是这样的
 写一个switch语句,为每个CASE打印一个消息。然后把这个switch放进FOR循环来测试CASE 写出输出结果
应该怎么写呢?? 用随即产生数 +循环?? 

解决方案 »

  1.   

    for里面嵌套 switch . 没什么难度吧.
                 for里面吧 switch所有可能都遍历一遍就可以了.
      

  2.   

    for里面可以弄一个递增的int 
    然后后面嵌套一个switch 楼上说的就是你需要的
      

  3.   


    public class Test {
    public static void main(String[] args) {
    for(int i=0; i<5; i++) {
    switch(i) {
    case 0:System.out.println(i);break;
    case 1:System.out.println(i);break;
    case 2:System.out.println(i);break;
    case 3:System.out.println(i);break;
    case 4:System.out.println(i);break;
    default:break;
    }
    }
    }
    }
    不知楼主想要的是不是这个