• java_枚举类枚举值


    package ming;
    
    enum Gender{
    	MALE("男"),FEMALE("女");
    	//public static final Gender MALE = new Gender("男");
    	private String name;
    
    	public String getName() {
    		return name;
    	}
    
    	private Gender(String name) {
    		this.name=name;
    	}
    	
    }
    
    public class enumTest {
    	public static void main(String[] args) {
    		// 通过valueof方法获取指定枚举类的值
    		Gender gf = Enum.valueOf(Gender.class, "FEMALE");
    		Gender gm = Enum.valueOf(Gender.class, "MALE");
    
    		System.out.println(gf+" is stand for "+gf.getName());
    		System.out.println(gm+" is stand for "+gm.getName());
    		
    	}
    
    }
    


  • 相关阅读:
    luogu4781
    luogu 4933
    luogu p1726
    bzoj2238
    luogu 1462 通往奥格瑞玛的道路
    noip.ac 3276 矩阵
    luogu1144
    noip.ac 3248
    奶牛比赛
    小P的Civilization V
  • 原文地址:https://www.cnblogs.com/MarchThree/p/3720469.html
Copyright © 2020-2023  润新知