Java中Switch选择结构的用法基本与C语言一致。一些笔记参看代码注释
package base.Select; import java.util.Scanner; public class switch01 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String grade; grade=scanner.nextLine(); switch (grade){ case "A":{ System.out.println("优秀"); break; } case "B": System.out.println("良好"); break; case "C": System.out.println("及格"); break; case "D": System.out.println("不及格"); break; default: System.out.println("错误"); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)