当用户输入错误的输入时显示错误消息
import java.util.Scanner; /** from * nowjava.com **/ public class Main { public static void main(String[] args) { int bank = 1000; int bet; // the bet entered by the user System.out.println("You can bet between 1 and " + bank); Scanner sc = new Scanner(System.in); do { System.out.print("Enter your bet: "); bet = sc.nextInt(); if ( (bet <= 0) || (bet > bank) )// 来 自 n o w j a v a . c o m - 时代Jav