javs switch 语句
Posted sea-stream
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javs switch 语句相关的知识,希望对你有一定的参考价值。
//switch statement import java.util.Scanner; public class Sample { public static void main(String[] args) { int num; Scanner ip = new Scanner(System.in); System.out.print("Enter number between 1 to 4: "); num = ip.nextInt(); switch (num) { case 1: System.out.println("Entered number is one"); break; case 2: System.out.println("Entered number is two"); break; case 3: System.out.println("Entered number is three"); break; case 4: System.out.println("Entered number is four"); break; default: System.out.println("invalid input"); } ip.close(); } } OUTPUT: Enter number between 1 to 4: 3 Entered number is three
以上是关于javs switch 语句的主要内容,如果未能解决你的问题,请参考以下文章