package com.demo.test; import java.util.Scanner; public class skip { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 根据条件跳过循环 for (int i = 1 ;i<=50; i++){ if (i==2||i==3||i==4){ // 只能在循环中使用 continue; } System.out.println("第"+i+"位顾客"); } //模拟用户登录,一共给三次机会 // 假设密码是123456 for (int i = 1; i <= 3; i++) { System.out.println("请输入密码:"); int password = sc.nextInt(); if (password == 123456) { System.out.println("登录成功!"); // 只能在循环或者是switch语句使用 break; } else { System.out.println("登录失败!"); } } } }
标签:java,Scanner,17,int,跳转,public From: https://www.cnblogs.com/wencaiguagua/p/17172021.html