1.whille循环格式:
package com.itheima.loop; public class While1 { public static void main(String[] args) { int i=0;//初始化语句 while(i<5){//循环条件 System.out.println(" ");//循环体语句 i++;//迭代语句,迭代语句不要丢掉了 } } }
2.珠穆拉玛峰案例:
package com.itheima.loop; public class While2 { public static void main(String[] args) { //实用while循环解决问题 //1.定义 double peakHeight=8848860; double paperThickness=0.1; int i=0; while(paperThickness<peakHeight){ paperThickness *=2; i++; } System.out.println(i); System.out.println(paperThickness); } }
标签:拉玛,java,int,while,循环,珠穆,public From: https://www.cnblogs.com/pengsuoqun123/p/17865170.html