zoukankan      html  css  js  c++  java
  • enum 枚举类型介绍

    package enumpractice;

    //运行下就差不多懂点了
    public enum Color {
    RED("红色",1),
    GREEN("绿色",2),
    NK("hhhhhh",1);
    private String name;
    private int index;
    private Color(String name, int index) {
    this.name = name;
    this.index = index;
    }
    /**
    * @return the name
    */
    public String getName() {
    return name;
    }
    /**
    * @param name the name to set
    */
    public void setName(String name) {
    this.name = name;
    }
    /**
    * @return the index
    */
    public int getIndex() {
    return index;
    }
    /**
    * @param index the index to set
    */
    public void setIndex(int index) {
    this.index = index;
    }
    public static String getName(int index){
    for(Color c: Color.values()){
    if(c.getIndex()==index){
    System.out.println(c.getName());
    //return c.name;
    }
    }
    System.out.println(Color.GREEN.getName());

    return "3123";

    }

    public static void main(String[] args) {
    getName(1);
    }


    }

  • 相关阅读:
    SpringBoot打jar包以及打成war包 (springboot2.0)
    学习软件开发的心得
    SQA计划
    继续冲吧
    别跑了,看看脚下有木有money
    springIOC的那些事
    ssm
    scrum 第二次冲刺
    云医院
    团队项目开发总结
  • 原文地址:https://www.cnblogs.com/ningkuan/p/8521047.html
Copyright © 2011-2022 走看看