控制台手动输入。

package enums;

import java.util.Scanner;

public class EnumTest {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a size:(SMALL,MEDIUM,LARGE,EXTRA_LARGE)");
String input = in.next().toUpperCase();
Size size = Enum.valueOf(Size.class, input);
System.out.println("size=" + size);
System.out.println("abbreviation=" + size.getAbbreviation());
if (size == size.EXTRA_LARGE)
System.out.print("Good job--you paid attention to the _.");
}
} enum Size {
SMALL("S"), MEDIUM("M"), LARGE("L"), EXTRA_LARGE("XL"); private Size(String abbreviation) {
this.abbreviation = abbreviation;
} public String getAbbreviation() {
return abbreviation;
} private String abbreviation;
}

enumerated types的更多相关文章

  1. VHDL之User-defined data types

    VHDL allows the user to define own data types. 1 user-defined integer types -- This is indeed the pr ...

  2. [Java面经]干货整理, Java面试题(覆盖Java基础,Java高级,JavaEE,数据库,设计模式等)

    如若转载请注明出处: http://www.cnblogs.com/wang-meng/p/5898837.html   谢谢.上一篇发了一个找工作的面经, 找工作不宜, 希望这一篇的内容能够帮助到大 ...

  3. iOS编码规范

      The official raywenderlich.com Objective-C style guide.   This style guide outlines the coding con ...

  4. JAVA编程思想(第四版)学习笔记----4.8 switch(知识点已更新)

    switch语句和if-else语句不同,switch语句可以有多个可能的执行路径.在第四版java编程思想介绍switch语句的语法格式时写到: switch (integral-selector) ...

  5. Thinking in Java——笔记(19)

    Enumerated Types Basic enum features When you create an enum, an associated class is produced for yo ...

  6. Java Programming Language Enhancements

    引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...

  7. CLR via C# 3rd - 07 - Constants and Fields

    1. Constants        A constant is a symbol that has a never-changing value. When defining a constant ...

  8. JPA 教程

    Entities An entity is a lightweight persistence domain object. Typically an entity represents a tabl ...

  9. Thinking in Java——笔记(5)

    Initialization & Cleanup Guaranteed initialization with the constructor In Java, the class desig ...

随机推荐

  1. Error Domain=AVFoundationErrorDomain Code=-11800 "这项操作无法完成"

    在iOS上开发视频操作的时候,出现错误: 录制视频错误:Error Domain=AVFoundationErrorDomain Code=-11800 "这项操作无法完成" Us ...

  2. 北京集训TEST13——PA(Goodness)

    题目: Description 桌面上放有 n 张卡牌.对于每张卡牌,一面是绿色的,另一面是红色的.卡牌的每一面都标有一个整数.对于卡牌a和卡牌b,卡牌a对卡牌b的好感度为卡牌a绿色面的数与卡牌b红色 ...

  3. out.print和out.write

    这是一个JSP页面: <%@ page language="java" import="java.util.*"  %> <%@ page p ...

  4. angular中ng-repeat去重

    [html] view plain copy print?在CODE上查看代码片派生到我的代码片 <div ng-app="myApp" ng-controller=&quo ...

  5. 能量项链(codevs 1154)

    题目描述 Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链.在项链上有N颗能量珠.能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数.并且,对于相邻的两颗珠子 ...

  6. POJ1861 Network

    Time Limit: 1000MS   Memory Limit: 30000KB   64bit IO Format: %lld & %llu Description Andrew is ...

  7. net3:Button的CommandName使用,AdRotator,BulletedList的使用

    原文发布时间为:2008-07-29 -- 来源于本人的百度文章 [由搬家工具导入] using System;using System.Data;using System.Configuration ...

  8. linux内核中预留4M以上大内存的方法

    在内核中, kmalloc能够分配的最大连续内存为2的(MAX_ORDER-1)次方个page(参见alloc_pages函数,     "if (unlikely(order >= ...

  9. unity的List构造函数在IOS平台存在缺陷

    当迩使用一个int[]或者string[]类似的数组时,以数组来初始化List对象,有可能在IOS平台上会出现初始化对象为空,比如 , }; List<int> listTest = ne ...

  10. js采用concat和sort将N个数组拼接起来的方法

    <script type="text/javascript" > function concatAndSortArray(array1, array2) { if (a ...