集册 Java实例教程 多种选择:开关盒

多种选择:开关盒

欢马劈雪     最近更新时间:2020-01-02 10:19:05

658
多种选择:开关盒

import java.util.Scanner;


public class Main {

  public static void main(String arg[]) {/*来自 NowJava.com*/

    System.out.print("Input a digit in [0..9]:");

    Scanner keyboard = new Scanner(System.in);

    int n = keyboard.nextInt();

    switch (n) {

    case 0:

      System.out.println("zero");

      break;

    case 1:

      System.out.println("one");

      break;

    case 2:

      System.out.println("two");

      break;// from n o w  j a v a  . c o m

    case 3:

      System.out.println("three");

   
展开阅读全文