作者在 2017-07-11 00:10:54 发布以下内容
package example;//break coninue
//主题 : 简易保险柜密码系统
import java.util.Scanner;
public class continue_break {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(true){ //while(1)会出错 reason:java中强制要求while()里面的值为boolean类型的 而c/c++没有此要求
System.out.println(";please input the password:");
int password=s.nextInt();
if(password!=123456){
continue;
}else{
break;
}
}// TODO Auto-generated method stub
System.out.println("the password is right");
}
}//continue : 跳过这次循环中剩余的语句,继续下一次循环
//break : 结束循环
//主题 : 简易保险柜密码系统
import java.util.Scanner;
public class continue_break {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while(true){ //while(1)会出错 reason:java中强制要求while()里面的值为boolean类型的 而c/c++没有此要求
System.out.println(";please input the password:");
int password=s.nextInt();
if(password!=123456){
continue;
}else{
break;
}
}// TODO Auto-generated method stub
System.out.println("the password is right");
}
}//continue : 跳过这次循环中剩余的语句,继续下一次循环
//break : 结束循环