Java基础(极客)——06、Java循环结构语句的特点和使用方法

/**
 * 2、用while循环打印所有大写英文字母和对应的Unicode码解法(1)
 * 
  【示例】用while循环打印所有大写英文字母和对应的unicode码
   解法(1)


 */

public class XunHuanDemo1 {
    public static void main(String[] args) {
        int i = 65;//65对应的unicode嗎是A
        while (i <= 65 + 25) {
            System.out.println((char) i + ":" + i);
            i++;


        }


    }


}//class



/**
 * 3、用while循环打印所有大写英文字母和对应的Unicode码解法(2)
 【示例】用while循环打印所有大写英文字母和对应的unicode码
解法(2)


 */

public class XunHuanDemo2 {
    public static void main(String[] args) {
        //在java中char底层室友int类型来处理的
        char c = 'A';
        while (c <= 'Z') {


            System.out.println(c + ":" + (int) c);
            c++;


        }
    }
}//class



/**
 * 4、Do While循环使用格式和执行流程
   do...while
    
   do {
       // 循环内容
      } while (循环继续的条件表达式);


   


 */

public class XunHuanDemo3 {
    public static void main(String[] args) {
        int i = 97;
        do {
            System.out.println((char) i + ":" + i);
            i++;
        } while (i <= 97 + 25);


    }
}//class



/**
 * 5、用Java do while循环打印所有大写英文字母和对应的Unicode码解法(1)
 * 6、用java do while循环打印所有大写英文字母和对应的Unicode码解法(2)
   do...while


 */

public class XunHuanDemo4 {
    public static void main(String[] args) {
        char c = 'a';
        do {
            System.out.println(c + ":" + (int) c);
            c++;
        } while (c <= 'z');


    }
}//class


/**
 *7、Java For循环语句的格式
   for循环


 */

public class XunHuanDemo5 {
    public static void main(String[] args) {
        /*执行顺序
         * 先执行i=1;
         * 判断i <= 20;
         * 执行大括号中的打印
         * i++;
         * 
         * 判断i <= 20;
         * 执行大括号中的打印
         * i++;
         * 
         * 
         * ***/
        for (int i = 1; i <= 20; i++) {
            System.out.println("做俯卧撑的次数:" + i);


        }


    }
}//class


源码下载:
http://download.csdn.net/detail/zhaihaohao1/8741715
视频下载:
http://c38.yunpan.360.cn/my/index/#%2F%E7%A8%8B%E5%BA%8F%E5%BC%80%E5%8F%91%2Fjava%2F

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值