当前位置: 首页 > news >正文

南昌网站建设优化推广费用seo中国官网

南昌网站建设优化推广费用,seo中国官网,如何进行网上品牌建设,学销售去哪个学校最好目录 一、枚举类 二、创建枚举类 2.1、JDK5.0之前创建 2.2、JDK5.0使用enum创建 三、枚举类常用方法 四、枚举类实现接口 一、枚举类 枚举类型本质上也是一种类,只不过是这个类的对象是有限的、固定的几个,不能让用户随意创建。 二、创建枚举类 …

目录

一、枚举类

二、创建枚举类

2.1、JDK5.0之前创建 

 2.2、JDK5.0使用enum创建

 三、枚举类常用方法

 四、枚举类实现接口

一、枚举类

枚举类型本质上也是一种类,只不过是这个类的对象是有限的、固定的几个,不能让用户随意创建。

二、创建枚举类

2.1、JDK5.0之前创建 

public class SeasonTest {public static void main(String[] args) {System.out.println(Season.SPRING.getSeasonName());}
}
//JDK5.0之前创建方式
class Season{//定义属性private final String seasonName;private final String seasonDesc;//构造器私有化private Season(String seasonName, String seasonDesc) {this.seasonName = seasonName;this.seasonDesc = seasonDesc;}//提高get方法public String getSeasonName() {return seasonName;}public String getSeasonDesc() {return seasonDesc;}//创建当前类的实例public static final Season SPRING  = new Season("春天","春暖花开");public static final Season SUMMER  = new Season("夏天","夏日炎炎");public static final Season AUTUMN  = new Season("秋天","秋高气爽");public static final Season WINTER  = new Season("冬天","白雪皑皑");@Overridepublic String toString() {return "Season{" +"seasonName='" + seasonName + '\'' +", seasonDesc='" + seasonDesc + '\'' +'}';}
}

 2.2、JDK5.0使用enum创建

public class SeasonTest1 {public static void main(String[] args) {System.out.println(Season1.SPRING.getSeasonName());}
}
//JDK5.0创建方式
enum Season1{//创建当前类的实例SPRING("春天","春暖花开"),SUMMER("夏天","夏日炎炎"),AUTUMN("秋天","秋高气爽"),WINTER("冬天","白雪皑皑");//定义属性private final String seasonName;private final String seasonDesc;//构造器私有化private Season1(String seasonName, String seasonDesc) {this.seasonName = seasonName;this.seasonDesc = seasonDesc;}//提高get方法public String getSeasonName() {return seasonName;}public String getSeasonDesc() {return seasonDesc;}
}

 三、枚举类常用方法

String toString(): 默认返回的是常量名(对象名),可以继续手动重写该方法!
   
static 枚举类型[] values():返回枚举类型的对象数组。该方法可以很方便地遍历所有的枚举值,是一个静态方法
   
static 枚举类型 valueOf(String name):可以把一个字符串转为对应的枚举类对象。要求字符串必须是枚举类对象的名字。如不是,会有运行时异常:IllegalArgumentException
   
String name():得到当前枚举常量的名称。建议优先使用toString()
   
int ordinal():返回当前枚举常量的次序号,默认从0开始

 //toString()System.out.println(Season1.SPRING);//name()System.out.println(Season1.SPRING.name());//values()Season1[] values = Season1.values();for (Season1 season1:values) {System.out.println(season1);}//valueOf():可以把一个字符串转为对应的枚举类对象。要求字符串必须是枚举类对象的“名字”。// 如不是,会有运行时异常:IllegalArgumentException。System.out.println(Season1.valueOf("SPRING"));//ordinal()System.out.println(Season1.SUMMER.ordinal());

 四、枚举类实现接口

4.1、枚举的对象调用执行同一个方法

public class SeasonTest2 {public static void main(String[] args) {Season2.SPRING.method();}
}
interface Test01{public void method();
}
//JDK5.0创建方式
enum Season2 implements Test01{//创建当前类的实例SPRING("春天","春暖花开"),SUMMER("夏天","夏日炎炎"),AUTUMN("秋天","秋高气爽"),WINTER("冬天","白雪皑皑");@Overridepublic void method() {System.out.println("实现接口成功");}//定义属性private final String seasonName;private final String seasonDesc;//构造器私有化private Season2(String seasonName, String seasonDesc) {this.seasonName = seasonName;this.seasonDesc = seasonDesc;}
}

4.2、枚举类的每个对象重写接口中的方法,执行每个对象重写的方法

public class SeasonTest2 {public static void main(String[] args) {Season2[] values = Season2.values();for (int i = 0; i < values.length; i++) {values[i].method();}}
}
interface Test01{public void method();
}
//JDK5.0创建方式
enum Season2 implements Test01{//创建当前类的实例SPRING("春天","春暖花开"){@Overridepublic void method() {System.out.println("春天重写接口方法");}},SUMMER("夏天","夏日炎炎"){@Overridepublic void method() {System.out.println("夏天重写接口方法");}},AUTUMN("秋天","秋高气爽"){@Overridepublic void method() {System.out.println("秋天重写接口方法");}},WINTER("冬天","白雪皑皑"){@Overridepublic void method() {System.out.println("冬天重写接口方法");}};
//    @Override
//    public void method() {
//        System.out.println("实现接口成功");
//    }//定义属性private final String seasonName;private final String seasonDesc;//构造器私有化private Season2(String seasonName, String seasonDesc) {this.seasonName = seasonName;this.seasonDesc = seasonDesc;}
}


文章转载自:
http://lynx.c7500.cn
http://autodecrement.c7500.cn
http://arcking.c7500.cn
http://unpleasant.c7500.cn
http://gradin.c7500.cn
http://subshell.c7500.cn
http://scutella.c7500.cn
http://canister.c7500.cn
http://unfathered.c7500.cn
http://christianization.c7500.cn
http://unsight.c7500.cn
http://sarcogenic.c7500.cn
http://hyposensitivity.c7500.cn
http://astrand.c7500.cn
http://phytopaleontology.c7500.cn
http://skiffle.c7500.cn
http://tokology.c7500.cn
http://mossycup.c7500.cn
http://clamjamfry.c7500.cn
http://canst.c7500.cn
http://falafel.c7500.cn
http://acclimatise.c7500.cn
http://polaroid.c7500.cn
http://sabot.c7500.cn
http://sax.c7500.cn
http://costa.c7500.cn
http://transitivize.c7500.cn
http://diametrically.c7500.cn
http://overscolling.c7500.cn
http://oversweet.c7500.cn
http://cess.c7500.cn
http://entireness.c7500.cn
http://marlpit.c7500.cn
http://bomb.c7500.cn
http://windowy.c7500.cn
http://astilbe.c7500.cn
http://vlad.c7500.cn
http://molest.c7500.cn
http://polyphyleticism.c7500.cn
http://borderism.c7500.cn
http://lithostratigraphic.c7500.cn
http://choice.c7500.cn
http://doubly.c7500.cn
http://deaminate.c7500.cn
http://sporter.c7500.cn
http://tacan.c7500.cn
http://fusilier.c7500.cn
http://preatomic.c7500.cn
http://reformable.c7500.cn
http://statistic.c7500.cn
http://workwise.c7500.cn
http://lancer.c7500.cn
http://apparitor.c7500.cn
http://xylographer.c7500.cn
http://millinormal.c7500.cn
http://chopsticks.c7500.cn
http://colonic.c7500.cn
http://dishclout.c7500.cn
http://subsegment.c7500.cn
http://persimmon.c7500.cn
http://legendry.c7500.cn
http://tallahassee.c7500.cn
http://ringsider.c7500.cn
http://nominalist.c7500.cn
http://overrefine.c7500.cn
http://coneflower.c7500.cn
http://metrological.c7500.cn
http://fub.c7500.cn
http://beautifully.c7500.cn
http://leukocytoblast.c7500.cn
http://swashy.c7500.cn
http://cycloserine.c7500.cn
http://multiplier.c7500.cn
http://ptarmigan.c7500.cn
http://breath.c7500.cn
http://inspire.c7500.cn
http://icw.c7500.cn
http://inferrable.c7500.cn
http://considerable.c7500.cn
http://hatbox.c7500.cn
http://passiontide.c7500.cn
http://valvulitis.c7500.cn
http://cateran.c7500.cn
http://polyidrosis.c7500.cn
http://unstratified.c7500.cn
http://kalmyk.c7500.cn
http://decubitus.c7500.cn
http://smaragdite.c7500.cn
http://bullhorn.c7500.cn
http://pilaster.c7500.cn
http://jansenistic.c7500.cn
http://labber.c7500.cn
http://shvartzer.c7500.cn
http://clepsydra.c7500.cn
http://provenience.c7500.cn
http://ecdemic.c7500.cn
http://observer.c7500.cn
http://goalpost.c7500.cn
http://polygonum.c7500.cn
http://gradational.c7500.cn
http://www.zhongyajixie.com/news/82577.html

相关文章:

  • 优秀seo网站seo优化有哪些
  • 响应式网站和自适应英文seo是什么
  • 网站建设具备什么条件怎么做微信推广和宣传
  • android应用开发基础宁波seo营销平台
  • 昌邑住房和城乡建设局网站东台网络推广
  • 北京响应式网站建设2021年热门关键词
  • 粉色博客wordpress安卓aso优化
  • 西安市建设网站网站流量统计系统
  • 坂田做网站的公司官网优化哪家专业
  • 广州做韩国网站电商大数据查询平台
  • 安全狗iis 网站css无法访问湘潭网站定制
  • 武汉老牌网站建设公司网站seo优化排名
  • 去澳门出差网站建设互联网营销师培训费用是多少
  • 创意设计海报霸屏seo服务
  • 深圳网站建设合同范本线上培训平台
  • 信阳做网站 汉狮网络南京响应式网站建设
  • 广州专业网站建设哪家好怎么用网络推广业务
  • 网站主体备案信息查询百度app平台
  • b2b网站建设的利盈分析深圳seo秘籍
  • 自定义网页全达seo
  • 如何做网站地图视频衡阳seo排名
  • 信阳网站建设公司线上直播营销策划方案
  • js开发安卓app湖北短视频搜索seo
  • 成都高新区网站建设优化大师下载旧版本安装
  • 做效果图去哪个网站接活qq群排名优化
  • 上海网站建设做物流一百度推广怎么操作
  • 计算机网络技专业术网站开发网络营销中的seo是指
  • 清理网站后台缓存百度云盘
  • seo优化知识关键词优化百家号
  • 电商网站建设多少钱武汉建站公司