java循环控制

java循环控制语句的应用:
1、斗地主循环发牌:
public class While{
    public static void main(String[] args){
       String[] actors = {"貂禅","吕布","董卓"};
       String[] cards = {"红桃A","红桃9","黑桃A","梅花A","红桃J","黑桃Q"};
       while(i < 6){
          String card = cards[i++ % 3];
          String actors  = actors[i];
          System.out.print(actors + ": " + card + "  ");
          if(i % 3 ){
              System.out.println();
          }
       }
     /** 也可以用for 循环实现,等回过头来再说吧,现在只能在这个环境下编辑,太难受了 */
    }
}

你可能感兴趣的:(while,for,do...while)