锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美一区视久久,永久免费在线,亚洲一区二区高清视频http://www.aygfsteel.com/DreamFight/articles/247522.htmlDreamFightDreamFightSat, 20 Dec 2008 10:03:00 GMThttp://www.aygfsteel.com/DreamFight/articles/247522.htmlhttp://www.aygfsteel.com/DreamFight/comments/247522.htmlhttp://www.aygfsteel.com/DreamFight/articles/247522.html#Feedback0http://www.aygfsteel.com/DreamFight/comments/commentRss/247522.htmlhttp://www.aygfsteel.com/DreamFight/services/trackbacks/247522.htmlEnum鏄痚numeration(鍒椾婦)鐨勭畝鍐欏艦寮?鍖呭惈鍦╦ava.lang鍖呬腑.鐔熸?zhèn)塁, C++, C#, 鎴?Pascal浜哄簲璇ュ鍒椾婦鏈夋墍浜?jiǎn)瑙?鍏堢湅涓緥瀛?

 public enum Season { winter, spring, summer, fall }


涓涓猠num鏄畾涔変竴緇勫肩殑瀵硅薄,瀹冨彲浠ュ寘鎷浂涓垨澶氫釜鍊兼垚鍛?瀹冩槸灞炰簬enum綾誨瀷鐨?涓涓猠num瀵硅薄涓笉鍙湁涓や釜鎴栧涓浉鍚岀殑灞炴ф垨鍊?鍦ㄦ涔嬪墠鐨刯ava紼嬪簭鍛樹竴鑸槸 鐢ㄦ帴鍙g殑鏂規(guī)硶瀹炵幇鍒椾婦鐨?濡?:

 

public interface Season {
    
static winter = 0;
    
static spring = 1//etc..
    }

寮曞叆浜?jiǎn)enum鐨刯ava鐨勫垪涓劇殑緙栧啓鏂逛究浜?jiǎn)璁稿?鍙』瀹氫箟涓涓猠num鍨嬬殑瀵硅薄.enum瀵硅薄鐨勫奸兘鍥炶嚜鍔ㄨ幏寰椾竴涓暟瀛楀?浠?寮濮?渚濇閫掑.鐪嬩竴涓瘮杈冪畝鍗曠殑enum瀹炵幇鐨勪緥瀛?EnumDemo.java

    /*
    We can loop over the values we put into the enum
    using the values() method.
    Note that the enum Seasons is compiled into a
    separate unit, called EnumDemo$Seasons.class
    
*/

    
public class EnumDemo {
    
/*declare the enum and add values to it. note that, like in C#, we don't use a ; to
    end this statement and we use commas to separate the values 
*/

    
private enum Seasons { winter, spring,
    summer, fall }

    
//list the values
    public static void main(String[] args) {
    
for (Seasons s : Seasons.values()){
    System.out.println(s);
    }

    }

    }

榪愯涓婅堪浠g爜浣犲洖寰楀埌 浠ヤ笅緇撴灉:

    winter
    spring
    summer
    fall
    Enum鐨勫睘鎬ц皟鐢?

    涓嬮潰鐨勪唬鐮佸睍紺轟簡(jiǎn)璋冪敤enum瀵硅薄鐨勬柟娉?榪欎篃鏄畠閫氬父鐨勭敤娉?

package net.javagarage.enums;
    
/*
    File: EnumSwitch.java
    Purpose: show how to switch against the values in an enum.
    
*/

    
public class EnumSwitch {
    
private enum Color { red, blue, green }
    
//list the values
    public static void main(String[] args) {
    
//refer to the qualified value
    doIt(Color.red);
    }

    
/*note that you switch against the UNQUALIFIED name. that is, "case Color.red:" is a
    compiler error 
*/

    
private static void doIt(Color c){
    
switch (c) {
    
case red:

    System.out.println(
"value is " + Color.red);
    
break;
    
case green:

    System.out.println(
"value is " + Color.green);
    
break;
    
case blue:

    System.out.println(
"value is : " + Color.blue);
    
break;
    
default :

    System.out.println(
"default");
    }

    }

    }



DreamFight 2008-12-20 18:03 鍙戣〃璇勮
]]>
java 涓殑 finalhttp://www.aygfsteel.com/DreamFight/articles/246576.htmlDreamFightDreamFightTue, 16 Dec 2008 02:50:00 GMThttp://www.aygfsteel.com/DreamFight/articles/246576.htmlhttp://www.aygfsteel.com/DreamFight/comments/246576.htmlhttp://www.aygfsteel.com/DreamFight/articles/246576.html#Feedback0http://www.aygfsteel.com/DreamFight/comments/commentRss/246576.htmlhttp://www.aygfsteel.com/DreamFight/services/trackbacks/246576.html 褰撲綘鍦ㄧ被涓畾涔夊彉閲忔椂錛屽湪鍏跺墠闈㈠姞涓奻inal鍏抽敭瀛楋紝閭d究鏄錛岃繖涓彉閲忎竴鏃﹁鍒濆鍖栦究涓嶅彲鏀瑰彉錛岃繖閲屼笉鍙敼鍙樼殑鎰忔濆鍩烘湰綾誨瀷鏉ヨ鏄叾鍊間笉鍙彉錛岃屽浜庡璞″彉閲忔潵璇村叾寮曠敤涓嶅彲鍐嶅彉銆傚叾鍒濆鍖栧彲浠ュ湪涓や釜鍦版柟錛屼竴鏄叾瀹氫箟澶勶紝涔熷氨鏄鍦╢inal鍙橀噺瀹氫箟鏃剁洿鎺ョ粰鍏惰祴鍊鹼紝浜屾槸鍦ㄦ瀯閫犲嚱鏁頒腑銆傝繖涓や釜鍦版柟鍙兘閫夊叾涓錛岃涔堝湪瀹氫箟鏃剁粰鍊鹼紝瑕佷箞鍦ㄦ瀯閫犲嚱鏁頒腑緇欏鹼紝涓嶈兘鍚屾椂鏃㈠湪瀹氫箟鏃剁粰浜?jiǎn)鍊鹼紝鍙堝湪鏋勯犲嚱鏁頒腑緇欏彟澶栫殑鍊箋?
final鏂規(guī)硶鏄湪媧劇敓綾諱腑涓嶈兘琚鐩栫殑鏂規(guī)硶,final綾繪槸涓嶈兘琚鐩栫殑綾匯備竴涓被鍙互鍚湁final鏂規(guī)硶final綾誨拰final鏂規(guī)硶浣跨敤final澹版槑鎶宸inal static綾誨瀷鎴愬憳鍙橀噺銆俿tatic浣垮緱鍙橀噺鍙瓨鍦ㄤ竴涓嫹璐濄俧inal浣垮緱瀹冧笉鑳芥敼鍙樸?

DreamFight 2008-12-16 10:50 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 内丘县| 红桥区| 攀枝花市| 新安县| 上犹县| 绥中县| 佛教| 尉氏县| 刚察县| 社旗县| 江陵县| 梓潼县| 剑川县| 石家庄市| 岑溪市| 高安市| 洛浦县| 清水河县| 信丰县| 苍梧县| 侯马市| 运城市| 万山特区| 会宁县| 灵川县| 大厂| 建德市| 双流县| 台江县| 神木县| 炉霍县| 吉木萨尔县| 积石山| 西安市| 上高县| 巨野县| 沂源县| 岫岩| 邳州市| 河南省| 阳城县|