主题:【原创】Java 1.5新特点的一些体验 -- 老兵帅客
An enumeration (enum) is a special form of value type, which inherits from System.Enum and supplies alternate names for the values of an underlying primitive type.
The following are the restrictions apply to an enum type in C#
1. They can’t define their own methods.
2. They can’t implement interfaces.
3. They can’t define properties or indexers.
In Tiger, the Java™ programming language gets linguistic support for enumerated types. In their simplest form, these enums look just like their C, C++, and C# counterparts: enum Season { WINTER, SPRING, SUMMER, FALL } But appearances can be deceiving. Java programming language enums are far more powerful than their counterparts in other languages, which are little more than glorified integers. The new enum declaration defines a full-fledged class (dubbed an enum type). In addition to solving all the problems mentioned above, it allows you to add arbitrary methods and fields to an enum type, to implement arbitrary interfaces, and more. Enum types provide high-quality implementations of all the Object methods. They are Comparable and Serializable, and the serial form is designed to withstand arbitrary changes in the enum type.
- 相关回复 上下关系8
😉我们是否应该使用这个Feature呢?Sun的观点是: Highway 字510 2004-10-03 22:03:57
4. Autoboxing and Unboxing 老兵帅客 字418 2004-10-02 18:36:38
3. Enumerated Types 老兵帅客 字2188 2004-10-02 18:25:47
.NET的enum和Java不一样,不是Class.
2. Generics 老兵帅客 字2941 2004-10-01 17:35:35
这里又一篇关于C# Generics的详细介绍,比较不错! Highway 字107 2004-10-02 06:56:30
1.3 Ordering Queues Using Comparators 老兵帅客 字1658 2004-10-01 16:46:18
.NET中有类似的东西。由于.NET使用delegate,而不是 Highway 字57 2004-10-01 16:57:05