⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enumdemo.java

📁 java 的好东西,,开发的基本语言语法教程
💻 JAVA
字号:
enum Apple {
  Jonathan,
  GoldenDel,
  RedDel,
  Winesap,
  Cortland
}
public class EnumDemo {
  public static void main(String args[])  
  {
    Apple ap;
 
    ap = Apple.RedDel;
    // Output an enum value. 
    System.out.println("Value of ap: " + ap);
    System.out.println();
 
    ap = Apple.GoldenDel;

    // Compare two enum values. 
    if(ap == Apple.GoldenDel)
      System.out.println("ap contains GoldenDel.\n");
 
    // Use an enum to control a switch statement. 
    switch(ap) {
      case Jonathan: 
        System.out.println("Jonathan is red."); 
        break; 
      case GoldenDel: 
        System.out.println("Golden Delicious is yellow."); 
        break; 
      case RedDel:  
        System.out.println("Red Delicious is red."); 
        break; 
      case Winesap:
        System.out.println("Winesap is red."); 
        break; 
      case Cortland:
        System.out.println("Cortland is red."); 
        break; 
    } 
  } 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -