• java学习first_day


    java枚举

    public class EnumMethodDemo {

      enum Color {RED, GREEN, BLUE;}

      enum Size {BIG, MIDDLE, SMALL;}

      public static void main(String args[]) {

       System.out.println("=========== Print all Color ===========");    //// =========== Print all Color ===========                

        for (Color c : Color.values()) {                     RED ordinal: GREEN ordinal: BLUE ordinal: 2      

          System.out.println(c + " ordinal: " + c.ordinal());

        }

         System.out.println("=========== Print all Size ===========");

        for (Size s : Size.values()) {

          System.out.println(s + " ordinal: " + s.ordinal());

        }

        Color green = Color.GREEN;

        System.out.println("green name(): " + green.name());

        System.out.println("green getDeclaringClass(): " + green.getDeclaringClass());

        System.out.println("green hashCode(): " + green.hashCode());

        System.out.println("green compareTo Color.GREEN: " + green.compareTo(Color.GREEN));

        System.out.println("green equals Color.GREEN: " + green.equals(Color.GREEN));

        System.out.println("green equals Size.MIDDLE: " + green.equals(Size.MIDDLE));

        System.out.println("green equals 1: " + green.equals(1));

        System.out.format("green == Color.BLUE: %b ", green == Color.BLUE); } }

  • 相关阅读:
    c++ 中的substr
    c++ 中将数字字符串转换成int输出的stoi() 和 atoi()
    c++ 四舍五入函数 round
    stddef.h----常用函数
    local.h-----地区函数
    errno.h-----定义出错代码
    signal.h-----信号函数
    stdio.h----标准的输入输出函数
    time.h-------日期与时间函数
    math.h--------数学函数
  • 原文地址:https://www.cnblogs.com/ybsport/p/12330852.html
Copyright © 2020-2023  润新知