混淆 枚举_与枚举混淆这里是一篇清楚的文章

混淆 枚举

让我们从枚举开始……(Let’s begin with enum …)

The following are important points about enum :

以下是有关枚举的要点:

  • An enum is a group of predefined named constant in any programming language.

    枚举是任何编程语言中的一组预定义的命名常量

  • Enum is used when we know all possible values of the group before compiling the code.

    当我们在编译代码之前知道该组的所有可能值时,将使用Enum。
  • Example: Direction can be an enum as we know all possible values of direction that can be NORTH, SOUTH, EAST, and WEST and declared using the enum keyword.

    示例: Direction可以是一个枚举,因为我们知道了Direction的所有可能值,可以是NORTH,SOUTH,EASTWEST,并使用 枚举关键字。

  • Over the course of development, we may add a few new enum constant.

    在开发过程中,我们可能会添加一些新的枚举常量

  • Enums are very powerful as they may have instance variables, instance methods, and constructors.

    枚举非常强大,因为它们可能具有实例变量,实例方法构造函数。

  • Each enum constant should be written in capital letters.

    每个枚举常量都应以大写字母表示。

  • Every enum constant is by default internally public static final of type Enum declared.

    默认情况下,每个枚举常量都是声明为Enum类型的内部公共静态最终形式。

我们来看一个枚举的例子: (Let’s see an example of enum :)

Enum example outside class 课堂外的枚举示例

输出:(OUTPUT :)

Direction name : NORTHDirection name : SOUTHDirection name : WESTDire
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值