博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
枚举类测试
阅读量:3949 次
发布时间:2019-05-24

本文共 988 字,大约阅读时间需要 3 分钟。

枚举类

package example.testForJava;public enum ResponseCodeEnum {
SUCCESS(1,"success"), FAIL(-1,"fail"), NOT_FOUND(404,"not found"); private Integer code; private String message; ResponseCodeEnum(Integer code,String message){
this.code=code; this.message=message; } public Integer getCode() {
return code; } public void setCode(Integer code) {
this.code = code; } public String getMessage() {
return message; } public void setMessage(String message) {
this.message = message; }}
package example.testForJava;public class CodeEnumTest {
public static void main(String[] args) {
String message=ResponseCodeEnum.SUCCESS.getMessage(); System.out.println(message); String message2=ResponseCodeEnum.FAIL.getMessage(); System.out.println(message2); Integer integer=ResponseCodeEnum.SUCCESS.getCode(); System.out.println(integer); }}

转载地址:http://xqrwi.baihongyu.com/

你可能感兴趣的文章
maven之pom.xml配置文件详解
查看>>
java基础学习之抽象类与接口的区别
查看>>
java基础学习之包、类、方法、属性、常量的命名规则
查看>>
java基础知识学习之匿名内部类
查看>>
SSM框架和SSH框架的区别
查看>>
漫画版Elasticsearch原理
查看>>
Elasticsearch-基础介绍及索引原理分析
查看>>
过滤敏感词算法
查看>>
linux学习之shell脚本if判断参数-n,-d,-f等
查看>>
linux学习之windos文件在linux里面乱码解决
查看>>
idea快捷键
查看>>
linux学习之shell遍历数组
查看>>
python函数取参及默认参数使用
查看>>
python中判断是否为路径与是否为文件用法
查看>>
linux学习之shell中的${},##, %% , :- ,:+, ? 的使用
查看>>
linux学习之eval使用
查看>>
Python 中 pass的使用
查看>>
Spring 配置详解
查看>>
Spring面向切面aop编程
查看>>
Spring学习之Filter、Interceptor、Aop实现与区别
查看>>