1、 JAVA一共有三种循环语句,分别是for、while、do……while。
1.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 =1;
while(q<10){
System.out.print("我是 : " + q );
q++;
}
}
}
1.3 do……while使用方法
public class Lesson2 {
public static void main(String args[]) {
int q =1;
do{
System.out.print("我是 : " + q );
q++;
}while(q<10)
}
}
2、 Break 用于跳出该循环,break是结束整个循环,contince是结束本次循环。
3、 Math .pwm();求某个数的平方
Doublepwm= Math .pwm(a.b)