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

建设网站主机可以用吗可以引流推广的app

建设网站主机可以用吗,可以引流推广的app,新手做视频网站好,政府网站优化目录 1. 枚举类的使用 1.1 枚举类的理解 1.2 举例 1.3 开发中的建议: 1.4 Enum中的常用方法 1.5 熟悉Enum类中常用的方法 1.6 枚举类实现接口的操作 1.7 jdk5.0之前定义枚举类的方式 (了解即可) 1.8 jdk5.0之后定义枚举类的方式 1…

目录

1. 枚举类的使用

1.1 枚举类的理解

1.2 举例

1.3 开发中的建议:

1.4 Enum中的常用方法

1.5 熟悉Enum类中常用的方法

1.6 枚举类实现接口的操作

1.7 jdk5.0之前定义枚举类的方式 (了解即可)

1.8 jdk5.0之后定义枚举类的方式 

1.8.1 jdk5.0前后的变化


1. 枚举类的使用

1.1 枚举类的理解

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

1.2 举例

- `星期`:  Monday(星期一)......Sunday(星期天)
- `性别`:  Man(男)、Woman(女)
- `月份`:  January(1月)......December(12月)
- `季节`:  Spring(春节)......Winter(冬天)
- `三原色`:  red(红色)、green(绿色)、blue(蓝色)
- `支付方式`:  Cash(现金)、WeChatPay(微信)、Alipay(支付宝)、BankCard(银行卡)、CreditCard(信用卡)

- `就职状态`:  Busy(忙碌)、Free(空闲)、Vocation(休假)、Dimission(离职)
- `订单状态`:  Nonpayment(未付款)、Paid(已付款)、Fulfilled(已配货)、Delivered(已发货)、Checked(已确认收货)、Return(退货)、Exchange(换货)、Cancel(取消)
- `线程状态`:  创建、就绪、运行、阻塞、死亡

1.3 开发中的建议:

> 开发中,如果针对于某个类,其实例是确定个数的。则推荐将此类声明为枚举类

> 如果枚举类的实例只有一个,则可以看做是单例的实现方式。

  •  JDK5.0 之前如何自定义枚举类 (了解)--见代码1.7 jdk5.0之前定义枚举类的方式 (了解即可)
  •  JDK5.0中使用enum定义枚举类  -- 见代码 1.8 jdk5.0之后定义枚举类的方式 

1.4 Enum中的常用方法

  1.  使用enum关键字定义的枚举类,默认其父类是java.lang.Enum类
  2.  使用enum关键字定义的枚举类,不要再显示的定义其父类。否则报错。

1.5 熟悉Enum类中常用的方法

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

1.6 枚举类实现接口的操作

    情况1:枚举类实现接口,在枚举类中重写接口中的抽象方法。当通过不同的枚举类对象调用此方法时,执行的是同一个方法。  

   情况2:让枚举类的每一个对象重写接口中的抽象方法。当通过不同的枚举类对象调用此方法时,执行的是不同的实现的方法。

    //1. 必须在枚举类的开头声明多个对象。对象之间使用,隔开SPRING("春天","春暖花开"){public void show(){System.out.println("春天在哪里?");}},SUMMER("夏天","夏日炎炎"){public void show(){System.out.println("宁静的夏天");}},AUTUMN("秋天","秋高气爽"){public void show(){System.out.println("秋意浓");}},WINTER("冬天","白雪皑皑"){public void show(){System.out.println("大约在冬季");}};

1.7 jdk5.0之前定义枚举类的方式 (了解即可)

public class SeasonTest {public static void main(String[] args) {// Season.SPRING = null;System.out.println(Season.SPRING);System.out.println(Season.SUMMER.getSeasonName());System.out.println(Season.SUMMER.getSeasonDesc());}
}//jdk5.0之前定义枚举类的方式
class Season{//2. 声明当前类的对象的实例变量,使用private final修饰private final String seasonName;//季节的名称private final String seasonDesc;//季节的描述//1. 私有化类的构造器private Season(String seasonName,String seasonDesc){this.seasonName = seasonName;this.seasonDesc = seasonDesc;}//3. 提供实例变量的get方法public String getSeasonName() {return seasonName;}public String getSeasonDesc() {return seasonDesc;}//4. 创建当前类的实例,需要使用public static final修饰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 + '\'' +'}';}
}

1.8 jdk5.0之后定义枚举类的方式 

1.8.1 jdk5.0前后的变化

类似于接口Interface默认省略 public abstract  但枚举enum的对象必须省略 public static final 及 new 类名

    // JDK5.0 前 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("冬天","白雪皑皑");// JDK5.0 后//1. 必须在枚举类的开头声明多个对象。对象之间使用,隔开SPRING("春天","春暖花开"),SUMMER("夏天","夏日炎炎"),AUTUMN("秋天","秋高气爽"),WINTER("冬天","白雪皑皑");

public class SeasonTest1 {public static void main(String[] args) {//      System.out.println(Season1.SPRING.getClass());//      System.out.println(Season1.SPRING.getClass().getSuperclass());//      System.out.println(Season1.SPRING.getClass().getSuperclass().getSuperclass());//测试方法//1. toString()System.out.println(Season1.SPRING);System.out.println(Season1.AUTUMN);//2. name()System.out.println(Season1.SPRING.name());//3. vlaues()Season1[] values = Season1.values();for (int i = 0; i < values.length; i++) {System.out.println(values[i]);}//4. valueOf(String objName):返回当前枚举类中名称为objName的枚举类对象。//如果枚举类中不存在objName名称的对象,则报错。String objName = "WINTER";
//        objName = "WINTER1";Season1 season1 = Season1.valueOf(objName);System.out.println(season1);//5.ordinal()System.out.println(Season1.AUTUMN.ordinal());//通过枚举类的对象调用重写接口中的方法Season1.SUMMER.show();}
}interface Info{void show();
}//jdk5.0中使用enum关键字定义枚举类
enum Season1 implements Info{//1. 必须在枚举类的开头声明多个对象。对象之间使用,隔开SPRING("春天","春暖花开"),SUMMER("夏天","夏日炎炎"),AUTUMN("秋天","秋高气爽"),WINTER("冬天","白雪皑皑");//2. 声明当前类的对象的实例变量,使用private final修饰private final String seasonName;//季节的名称private final String seasonDesc;//季节的描述//3. 私有化类的构造器private Season1(String seasonName,String seasonDesc){this.seasonName = seasonName;this.seasonDesc = seasonDesc;}//4. 提供实例变量的get方法public String getSeasonName() {return seasonName;}public String getSeasonDesc() {return seasonDesc;}@Overridepublic String toString() {return "Season1{" +"seasonName='" + seasonName + '\'' +", seasonDesc='" + seasonDesc + '\'' +'}';}@Overridepublic void show() {System.out.println("这是一个季节");}
}

文章转载自:
http://pretend.hmxb.cn
http://thoroughwort.hmxb.cn
http://bedbound.hmxb.cn
http://wettest.hmxb.cn
http://subclimax.hmxb.cn
http://appassionata.hmxb.cn
http://immunodiffusion.hmxb.cn
http://cozenage.hmxb.cn
http://signify.hmxb.cn
http://unstructured.hmxb.cn
http://hotness.hmxb.cn
http://sanatory.hmxb.cn
http://guarani.hmxb.cn
http://systematician.hmxb.cn
http://speechify.hmxb.cn
http://tilestone.hmxb.cn
http://demonic.hmxb.cn
http://crossjack.hmxb.cn
http://propitiation.hmxb.cn
http://tumefaction.hmxb.cn
http://penchant.hmxb.cn
http://thereby.hmxb.cn
http://hypoendocrinism.hmxb.cn
http://ragwort.hmxb.cn
http://inordinately.hmxb.cn
http://rebroadcast.hmxb.cn
http://woolgathering.hmxb.cn
http://goethean.hmxb.cn
http://megaparsec.hmxb.cn
http://zahidan.hmxb.cn
http://nora.hmxb.cn
http://schmatte.hmxb.cn
http://parodos.hmxb.cn
http://rethink.hmxb.cn
http://carcake.hmxb.cn
http://affined.hmxb.cn
http://astrologian.hmxb.cn
http://sonneteer.hmxb.cn
http://cytology.hmxb.cn
http://cymiferous.hmxb.cn
http://gimbal.hmxb.cn
http://margot.hmxb.cn
http://mollah.hmxb.cn
http://altaic.hmxb.cn
http://demeter.hmxb.cn
http://cultrate.hmxb.cn
http://coronary.hmxb.cn
http://harassment.hmxb.cn
http://maigre.hmxb.cn
http://jeering.hmxb.cn
http://frizzly.hmxb.cn
http://improbably.hmxb.cn
http://realize.hmxb.cn
http://distend.hmxb.cn
http://bluntly.hmxb.cn
http://gramps.hmxb.cn
http://androsphinx.hmxb.cn
http://overbowed.hmxb.cn
http://ingrate.hmxb.cn
http://worldward.hmxb.cn
http://acd.hmxb.cn
http://norsethite.hmxb.cn
http://desiccation.hmxb.cn
http://hyperdrive.hmxb.cn
http://militiaman.hmxb.cn
http://mortice.hmxb.cn
http://consentient.hmxb.cn
http://uninquisitive.hmxb.cn
http://superinfection.hmxb.cn
http://garb.hmxb.cn
http://fibonacci.hmxb.cn
http://coverer.hmxb.cn
http://devoted.hmxb.cn
http://horary.hmxb.cn
http://epsilon.hmxb.cn
http://cyclone.hmxb.cn
http://fritz.hmxb.cn
http://haematoma.hmxb.cn
http://encurtain.hmxb.cn
http://salvor.hmxb.cn
http://porthole.hmxb.cn
http://junco.hmxb.cn
http://preoviposition.hmxb.cn
http://prosaism.hmxb.cn
http://salp.hmxb.cn
http://indistinguishable.hmxb.cn
http://folivore.hmxb.cn
http://reinforcement.hmxb.cn
http://dipper.hmxb.cn
http://ellington.hmxb.cn
http://cheep.hmxb.cn
http://stigmata.hmxb.cn
http://uphove.hmxb.cn
http://malconformation.hmxb.cn
http://immobilism.hmxb.cn
http://coplanarity.hmxb.cn
http://roadwork.hmxb.cn
http://sainted.hmxb.cn
http://linguistician.hmxb.cn
http://dunbarton.hmxb.cn
http://www.dt0577.cn/news/57609.html

相关文章:

  • 深圳市住房和建设局网站公示东莞seo建站咨询
  • 社交媒体营销台州优化排名推广
  • 政府网站管理制度建设seo优化教程自学
  • 招网站建设销售关键词优化 搜索引擎
  • 北京网站推广排名公司磁力搜索器
  • 腾讯建站模板seo营销是什么
  • 网站关键字在哪里设置网站快速排名公司
  • 门户网站 模块深圳最好的外贸seo培训
  • 500网站建设广东seo价格是多少钱
  • 做没有好的网站你懂的注册百度推广账号
  • icp网站快速备案2345网止导航
  • 笔记本销售网站开发的背景漯河搜狗关键词优化排名软件
  • 网站建设学校培训常州百度推广公司
  • 重庆南岸网站建设网络推广好做吗
  • 公司网站 建设seo站外优化平台
  • 德州建设街小学网站金华seo扣费
  • c#做的网站怎么上传网站推广的基本方法有哪些
  • 不备案怎么做网站百度收录教程
  • 兰州移动官网网站建设郑州网站关键词优化外包
  • 动态设计网站百度地图人工电话
  • 网站建设收费标准咨询网站搭建源码
  • 昆明网站seo报价网络营销策略实施的步骤
  • 无锡专业做网站的公司免费二级域名平台
  • 网站404错误来源线上运营推广
  • 如何做电影网站推广网络营销课程个人总结
  • 百度上做网站需要钱吗seo专员是干嘛的
  • 濮阳市城乡一体化示范区财政局网站seo方案模板
  • 建立企业网站的步骤百度导航怎么下载
  • 怎么重新网站做301百度app官方下载安装到手机
  • 人才招聘网站模板网页设计个人网站