From 73a7ece68bc71a2665329cec86a50499ebc4bdde Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Thu, 16 Jul 2026 15:46:06 +0800 Subject: [PATCH] =?UTF-8?q?day03-=E5=BE=AA=E7=8E=AF=E6=B5=81=E7=A8=8B-for?= =?UTF-8?q?=E5=BE=AA=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day03/src/com/inmind/for03/Demo05.java | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 day03/src/com/inmind/for03/Demo05.java diff --git a/day03/src/com/inmind/for03/Demo05.java b/day03/src/com/inmind/for03/Demo05.java new file mode 100644 index 0000000..aa51c86 --- /dev/null +++ b/day03/src/com/inmind/for03/Demo05.java @@ -0,0 +1,47 @@ +package com.inmind.for03; +/* +for , while ,do-while 循环 +循环三要素:循环变量初始化、循环条件、修改循环变量 + +for循环的格式: +for(循环变量初始化①;循环条件②;修改循环变量④){ + 循环语句③ +} + +执行顺序:①②③④>②③④>②③④…②不满足为止。 + +*/ +public class Demo05 { + public static void main(String[] args) { + //打印1~10的值 + for(int i = 1;i<=10;i++){ + System.out.println(i); + } + System.out.println("程序结束"); + System.out.println("-----------------------"); + //打印10~1的值 + for(int j = 10;j>=1;j--){ + System.out.println(j); + } + + System.out.println("-----------------------"); + //打印a~z的值字符 a = 97 z = 122 + for(int i = 97; i <=122;i++){ + System.out.println((char) i); + } + System.out.println("-----------------------"); + for (char i = 'a'; i <= 'z'; i++) { + System.out.println(i); + } + System.out.println("-----------------------"); + for (char i = 'z'; i >= 'a'; i--) { + System.out.println(i); + } + System.out.println("-----------------------"); + + //打印100次"hello world" + for (int i = 1; i <= 100; i++) { + System.out.println("helloworld"); + } + } +}