if 跟 while 语句的区别
if 和 while 语句的区别。
1:代码
写道
public class Test {
public static void main(String[] args) {
int whileInteger = 3,ifInteger = 3;
while(--whileInteger>=0){
System.out.println(String.format("while:第%s次打印", whileInteger));
}
if(--ifInteger>=0){
System.out.println(String.format("if:第%s次打印", ifInteger));
}
}
}
public static void main(String[] args) {
int whileInteger = 3,ifInteger = 3;
while(--whileInteger>=0){
System.out.println(String.format("while:第%s次打印", whileInteger));
}
if(--ifInteger>=0){
System.out.println(String.format("if:第%s次打印", ifInteger));
}
}
}
2:输入结果。
3:while是用来循环判断的。