• 20170215学习计划


    1.Springboot框架 http://blog.csdn.net/isea533/article/details/50278205       http://jinnianshilongnian.iteye.com/blog/1997192

    2.docker百度云视频

    3.jsp基础教程-菜鸟教程看完

    4.使用springboot、mybatis框架开始houji项目

    5.ssh免密码

    6.java中enum枚举的使用方法http://www.cnblogs.com/frankliiu-java/archive/2010/12/07/1898721.html

    EnumTest.values()对应值,定义的private String context则为括号里的值,具体参考Enum类中的所有方法:

     1 enum Color{  
     2                 RED(255,0,0),BLUE(0,0,255),BLACK(0,0,0),YELLOW(255,255,0),GREEN(0,255,0);  
     3                 //构造枚举值,比如RED(255,0,0)  
     4                 private Color(int rv,int gv,int bv){  
     5                  this.redValue=rv;  
     6                  this.greenValue=gv;  
     7                  this.blueValue=bv;  
     8                 }  
     9   
    10                 public String toString(){  //覆盖了父类Enum的toString()  
    11                 return super.toString()+"("+redValue+","+greenValue+","+blueValue+")";  
    12                 }  
    13      
    14                 private int redValue;  //自定义数据域,private为了封装。  
    15                 private int greenValue;  
    16                 private int blueValue;  
    17  } 

    (1)  ordinal()方法: 返回枚举值在枚举类种的顺序。这个顺序根据枚举值声明的顺序而定。
                     Color.RED.ordinal();  //返回结果:0
                     Color.BLUE.ordinal();  //返回结果:1
           (2)  compareTo()方法: Enum实现了java.lang.Comparable接口,因此可以比较象与指定对象的顺序。Enum中的compareTo返回的是两个枚举值的顺序之差。当然,前提是两个枚举值必须属于同一个枚举类,否则会抛出ClassCastException()异常。(具体可见源代码)
                     Color.RED.compareTo(Color.BLUE);  //返回结果 -1
           (3)  values()方法: 静态方法,返回一个包含全部枚举值的数组。
                     Color[] colors=Color.values();
                     for(Color c:colors){
                            System.out.print(c+","); 
                     }//返回结果:RED,BLUE,BLACK YELLOW,GREEN,
           (4)  toString()方法: 返回枚举常量的名称。
                     Color c=Color.RED;
                     System.out.println(c);//返回结果: RED
           (5)  valueOf()方法: 这个方法和toString方法是相对应的,返回带指定名称的指定枚举类型的枚举常量。
                     Color.valueOf("BLUE");   //返回结果: Color.BLUE
           (6)  equals()方法: 比较两个枚举类对象的引用。

    public enum EnumTest {
         FRANK("The given name of me"),
         LIU("The family name of me");
         private String context;
         private String getContext(){
          return this.context;
         }
         private EnumTest(String context){
          this.context = context;
         }
         public static void main(String[] args){
          for(EnumTest name :EnumTest.values()){
          System.out.println(name+" : "+name.getContext());
          }
          System.out.println(EnumTest.FRANK.getDeclaringClass());
         }

  • 相关阅读:
    Mysql索引优化分析
    mysql学习
    linux安装mysql
    MVC实例应用模式
    模型-视图-控制器MVC模式
    设计模式理解
    XX系统质量属性战术
    XX系统可用性易用性
    属性常见属性场景
    架构漫谈读后感
  • 原文地址:https://www.cnblogs.com/zipon/p/6400467.html
Copyright © 2020-2023  润新知