Java 枚举对象的使用

来源:互联网 发布:备份数据库的sql语句 编辑:程序博客网 时间:2024/05/16 09:43
public class TestEM {public static void main(String[] args) {Queue<Video> q = new LinkedList<>();q.add(Video.前门);q.add(Video.后门);System.out.println(q.poll().getName());System.out.println(q.poll().getName());}public enum Video {前门("前门", 1, 1), 后门("后门", 2, 2), 中门("中门", 3, 3), 倒车("倒车", 4, 4);// 成员变量private String name;private int index;private int priority;// 构造方法private Video(String name, int index, int priority) {this.name = name;this.index = index;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getIndex() {return index;}public void setIndex(int index) {this.index = index;}public int getPriority() {return priority;}public void setPriority(int priority) {this.priority = priority;}}}

0 0
原创粉丝点击