Demo09.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.loveCoding.j20250426_java_basic;
  2. /**
  3. * @author WanJl
  4. * @version 1.0
  5. * @title Demo09
  6. * @description
  7. * @create 2025/4/26
  8. */
  9. public class Demo09 {
  10. public static void main(String[] args) {
  11. /*
  12. for(int i=0;i<10;i++){
  13. System.out.println(i)
  14. }
  15. for(初始化语句;循环条件;迭代语句){
  16. 循环体
  17. }
  18. int i=0; 初始化语句
  19. while(i<10){ 循环条件
  20. System.out.println(i); 循环体
  21. i++; 迭代语句
  22. }
  23. int i=0; 初始化语句
  24. do{
  25. System.out.println(i); 循环体
  26. i++; 迭代语句
  27. }while(i<10); 循环条件
  28. 循环语句的执行步骤
  29. 1、先执行初始化语句
  30. 2、执行判断条件语句,如果判断结果为true,则执行3,为false则执行5
  31. 3、执行循环体
  32. 4、执行迭代语句,执行第2。
  33. 5、结束循环
  34. */
  35. /*
  36. 1、编写代码,计算出1000以内的水仙花数。
  37. 例如:153。1*100+5*10+3 == 1^3+5^3+3^3 满足条件则是水仙花数
  38. 100以上的三位数,这个数的个位+十位+百位的结果和这个数的每个位上的值的3次方相等
  39. */
  40. /*
  41. for (;; ) {
  42. System.out.println("hello");
  43. }
  44. while(true){
  45. System.out.println("hello");
  46. }
  47. */
  48. }
  49. }