从控制台读取数字并使用开关检查值
import java.util.Scanner; /* 时代Java公众号 提 供 */ public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.print("Enter the error code: "); int err = sc.nextInt(); String msg; /* 来自 *nowjava.com*/ switch (err) { case 1: msg = "1."; break; case 2: msg = "2."; break; case 3: msg = "3."; break; case 4: msg = "4."; break; case 5: msg = "5."; break; case 6: msg = "6."; break; case 7: