<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java 5 中的enum的深入學(xué)習(xí)心得

    The full enum syntax actually provides quite a bit more power and flexibility:
    
    • You can define your own fields, methods, and constructors for the enumerated type.

    • If you define one or more constructors, you can invoke a constructor for each enumerated value by following the value name with constructor arguments in parentheses.

    • Although an enum may not extend anything, it may implement one or more interfaces.

    • Most esoterically, individual enumerated values can have their own class bodies that override methods defined by the type.

    Rather than formally specifying the syntax for each of these advanced enum declarations, we'll demonstrate the syntax in the examples that follow.

     
    for example:
     
    public enum Prefix {
    // These are the values of this enumerated type.
    // Each one is followed by constructor arguments in parentheses.
    // The values are separated from each other by commas, and the
    // list of values is terminated with a semicolon to separate it from
    // the class body that follows.
    MILLI("m",    .001),
    CENTI("c",    .01),
    DECI("d",     .1),
    DECA("D",   10.0),
    HECTA("h", 100.0),
    KILO("k", 1000.0);  // Note semicolon
    // This is the constructor invoked for each value above.
    Prefix(String abbrev, double multiplier) {
    this.abbrev = abbrev;
    this.multiplier = multiplier;
    }
    // These are the private fields set by the constructor
    private String abbrev;
    private double multiplier;
    // These are accessor methods for the fields.  They are instance methods
    // of each value of the enumerated type.
    public String abbrev() { return abbrev; }
    public double multiplier() { return multiplier; }
    }

    posted on 2007-12-06 10:55 劉錚 閱讀(437) 評論(0)  編輯  收藏 所屬分類: JAVA General

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導(dǎo)航

    統(tǒng)計

    留言簿(1)

    文章分類(141)

    文章檔案(147)

    搜索

    最新評論

    主站蜘蛛池模板: 无码少妇一区二区浪潮免费| h视频在线免费看| 亚洲?V无码乱码国产精品 | 日本免费一区尤物| 精品亚洲456在线播放| 丁香亚洲综合五月天婷婷| 亚洲色大18成人网站WWW在线播放 亚洲色大成WWW亚洲女子 | 久久亚洲欧洲国产综合| 成人免费夜片在线观看| 丁香五月亚洲综合深深爱| 一级毛片免费在线播放| 国产亚洲精品美女久久久| 十八禁在线观看视频播放免费| 国产成人午夜精品免费视频| 国产精品亚洲精品观看不卡| 成人毛片免费在线观看| 久久精品国产亚洲av瑜伽| 亚洲精品A在线观看| 热99RE久久精品这里都是精品免费| 亚洲第一成年男人的天堂| 亚洲精品视频在线观看免费| 亚洲欧美日韩综合久久久久| 国产一区二区三区在线观看免费| 免费国产va在线观看| 亚洲日韩欧洲乱码AV夜夜摸| 免费A级毛片无码专区| 亚洲人成网站在线播放2019| 亚洲国产激情一区二区三区| 热99RE久久精品这里都是精品免费| 亚洲字幕在线观看| 四虎永久免费观看| 久9这里精品免费视频| 日韩亚洲人成在线| 中文字幕亚洲激情| 亚欧在线精品免费观看一区| 自拍偷自拍亚洲精品偷一| 自拍偷自拍亚洲精品被多人伦好爽| 蜜桃成人无码区免费视频网站| 亚洲码欧美码一区二区三区| 国外亚洲成AV人片在线观看| 亚洲免费福利视频|