说明

  1. 枚举类:需要继承Enumeration<br /> 应用类:需要继承App

案例实操

object Test {
    def main(args: Array[String]): Unit = {
        println(Color.RED)
    }
}
// 枚举类
object Color extends Enumeration {
    val RED = Value(1, "red")
    val YELLOW = Value(2, "yellow")
    val BLUE = Value(3, "blue")
}
// 应用类
object Test20 extends App {
    println("xxxxxxxxxxx");
}