第5节:Java 循环结构【多测师_王sir】

1、    JAVA一共有三种循环语句,分别是for、whiledo……while1.1    For使用方法
public class Lesson1 {
publicstatic void main(String args[]) {
for(int q = 1; q < 10; q = q+1) {
System.out.print("我是 : " + q );
}
}
}
1.2    While 使用方法
public class Lesson2 {
publicstatic void main(String args[]) {
int q =1while(q<10){
System.out.print("我是 : " + q );
q++;
}
}
}
1.3    do……while使用方法
public class Lesson2 {
public static void main(String args[]) {
int q =1do{
System.out.print("我是 : " + q );
q++;
}while(q<10)
}
}
2、    Break 用于跳出该循环,break是结束整个循环,contince是结束本次循环。
3、    Math .pwm();求某个数的平方
Doublepwm= Math .pwm(a.b)
原文地址:https://www.cnblogs.com/xiaoshubass/p/13601731.html