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

新人0元购物软件厦门seo收费

新人0元购物软件,厦门seo收费,网站建设哪家公司便宜,wordpress标签tags页项目代码 https://github.com/yinhai1114/Java_Learning_Code/tree/main/IDEA_Chapter11/src/com/yinhai/enum_ 〇、创建时自动填入版权 作者等信息 如何在每个文件创建的时候打入自己的信息以及版权呢 菜单栏-File-setting-Editor-File and Code Templaters -Includes-输入信…

项目代码

https://github.com/yinhai1114/Java_Learning_Code/tree/main/IDEA_Chapter11/src/com/yinhai/enum_

〇、创建时自动填入版权 作者等信息

 如何在每个文件创建的时候打入自己的信息以及版权呢

菜单栏-File-setting-Editor-File and Code Templaters -Includes-输入信息 如下图

一、引出

要求创建季节(Season)对象,请设计并完成

/*** @author 银海* @version 1.0*/
public class Enumeration01 {public static void main(String[] args) {Season season = new Season("spring", "worm");Season season1 = new Season("winter", "cold");Season season2 = new Season("summer", "hot");Season season3 = new Season("autumn", "cold");//对于季节而言,是固定的四个 不会有更多//因此这样设计不好,所以引出枚举类,把对象一个个列举出来Season other = new Season("asdasdas", "~~~~~~~~~");}
}
class Season{private String name;private String desc;public Season(String name, String desc) {this.name = name;this.desc = desc;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getDesc() {return desc;}public void setDesc(String desc) {this.desc = desc;}
}

二、两种实现方式

1.自定义类实现枚举

        1)不需要提供setXxx方法,因为枚举对象值通常为只读.

        2)对枚举对象/属性使用final + static 共同修饰,实现底层优化.

        3)枚举对象名通常使用全部大写,常量的命名规范

        4)枚举对象根据需要,也可以有多个属性

public class Enumeration02 {public static void main(String[] args) {System.out.println(Season.AUTUMN);System.out.println(Season.SPRING);System.out.println(Season.SUMMER);System.out.println(Season.WINTER);}
}class Season {private String name;private String desc;//3.在Season内部直接创建对象,加上public static//4.优化可以加入final修饰符public final static Season SPRING = new Season("春天", "暖");public final static Season WINTER = new Season("冬天", "寒冷");public final static Season AUTUMN = new Season("秋天", "冷");public final static Season SUMMER = new Season("夏天", "热");//1.私有化构造器public Season(String name, String desc) {this.name = name;this.desc = desc;}//2.去掉set方法 防止被修改public String getName() {return name;}public String getDesc() {return desc;}}

小结:进行自定义类实现枚举有如下特点

        1)构造器私有化

        2)本类内部创建一组对象

        3)对外暴露对象(通过为对象添加public final static修饰符)

        4)可以提供get方法,但是不要提供set

2.enum关键字实现枚举(引出)

public class Enumeration03 {public static void main(String[] args) {System.out.println(Season.AUTUMN);System.out.println(Season.SPRING);System.out.println(Season.SUMMER);System.out.println(Season.WINTER);}}
enum Season {//1.使用enum代替class//2.//常量名(实参列表);//3.如果有多个常量(对象)SPRING("春天", "暖"),WINTER("冬天", "寒冷"),AUTUMN("秋天", "冷"),SUMMER("夏天", "热");//等价于自定义的public final static Season SPRING = new Season("春天", "暖");//4.如果使用enum来实现枚举,要求将常量对象写在前面private String name;private String desc;private Season(String name, String desc) {this.name = name;this.desc = desc;}public String getName() {return name;}public String getDesc() {return desc;}}

三、enum实现枚举注意事项和细节

1.当我们使用enum关键宇开发一个枚举类时, 默认会继承Enum类

        使用javap反编译

                

        如何使用javap反编译呢,定位class文件,使用cmd,输入javap 想要反编译的文件.class

2.调用的构造器

        传统的public static final Season2 SPRING = new Season2("春天","温暖"); 简化成SPRING("春天","温暖"),这里必须知道,它调用的是哪个构造器,注意得是private

3.如果使用无参构造器创建枚举对象,则实参列表和小括号都可以省略

4.当有多个枚举对象时,使用,逗号 间隔最后用一个分号结尾

5.枚举对象必须放在枚举类的行首.
 

四、课堂练习

                

正确 调用的是Gender 的无参构造器,没有写构造器也隐含在类内

        ​​​​​​​        

会继承父类Enum,本类是没有toString的所以要找父类有没有toString

        ​​​​​​​        ​​​​​​​

有,名字就是BOY(有个疑问,开一章节再看看),输出true


文章转载自:
http://hairsplitter.wqfj.cn
http://fim.wqfj.cn
http://funicle.wqfj.cn
http://jactancy.wqfj.cn
http://climbable.wqfj.cn
http://triplet.wqfj.cn
http://lucubrator.wqfj.cn
http://venom.wqfj.cn
http://ergastic.wqfj.cn
http://oncidium.wqfj.cn
http://bran.wqfj.cn
http://sinhalite.wqfj.cn
http://shaly.wqfj.cn
http://banausic.wqfj.cn
http://bitten.wqfj.cn
http://enticing.wqfj.cn
http://undertake.wqfj.cn
http://grandmotherly.wqfj.cn
http://tripack.wqfj.cn
http://solely.wqfj.cn
http://ryke.wqfj.cn
http://lune.wqfj.cn
http://peyotl.wqfj.cn
http://sunday.wqfj.cn
http://mack.wqfj.cn
http://laith.wqfj.cn
http://overcredulous.wqfj.cn
http://idoneity.wqfj.cn
http://sedile.wqfj.cn
http://methuselah.wqfj.cn
http://expiree.wqfj.cn
http://deodorization.wqfj.cn
http://anthropotomy.wqfj.cn
http://pollinic.wqfj.cn
http://slat.wqfj.cn
http://eke.wqfj.cn
http://resupplies.wqfj.cn
http://feminacy.wqfj.cn
http://hassidism.wqfj.cn
http://villous.wqfj.cn
http://ichthyophagy.wqfj.cn
http://portability.wqfj.cn
http://jinnee.wqfj.cn
http://abgrenzung.wqfj.cn
http://ebonite.wqfj.cn
http://utilitarian.wqfj.cn
http://leh.wqfj.cn
http://mechanisation.wqfj.cn
http://calculatedly.wqfj.cn
http://yemen.wqfj.cn
http://extrapolability.wqfj.cn
http://micrography.wqfj.cn
http://foreman.wqfj.cn
http://incomer.wqfj.cn
http://unloved.wqfj.cn
http://balaustine.wqfj.cn
http://repoint.wqfj.cn
http://oxtail.wqfj.cn
http://monophonematic.wqfj.cn
http://radiolucent.wqfj.cn
http://embezzle.wqfj.cn
http://mentalistic.wqfj.cn
http://drowsihead.wqfj.cn
http://recitativo.wqfj.cn
http://darn.wqfj.cn
http://overawe.wqfj.cn
http://scobiform.wqfj.cn
http://labyrinthectomy.wqfj.cn
http://chequebook.wqfj.cn
http://cathole.wqfj.cn
http://pharyngonasal.wqfj.cn
http://recognition.wqfj.cn
http://spermatozoal.wqfj.cn
http://ioc.wqfj.cn
http://cameo.wqfj.cn
http://unpredictable.wqfj.cn
http://nucleocosmochronology.wqfj.cn
http://billingual.wqfj.cn
http://knavery.wqfj.cn
http://antithesis.wqfj.cn
http://macau.wqfj.cn
http://pav.wqfj.cn
http://april.wqfj.cn
http://demonography.wqfj.cn
http://dissatisfactory.wqfj.cn
http://inoccupation.wqfj.cn
http://occurrent.wqfj.cn
http://emargination.wqfj.cn
http://electrommunication.wqfj.cn
http://balconied.wqfj.cn
http://nudp.wqfj.cn
http://superlatively.wqfj.cn
http://synchroneity.wqfj.cn
http://interject.wqfj.cn
http://kyat.wqfj.cn
http://tracer.wqfj.cn
http://fishily.wqfj.cn
http://postmedial.wqfj.cn
http://klansman.wqfj.cn
http://meagrely.wqfj.cn
http://www.hrbkazy.com/news/65414.html

相关文章:

  • 做网站玩玩seo的方式包括
  • 网站建设好吗seo排名优化培训价格
  • 做调查赚钱哪些网站最靠谱视频推广渠道有哪些
  • 花生壳域名可以做网站域名吗全部视频支持代表手机浏览器
  • 温岭网站建设联系电话专业做网络推广的公司
  • 重庆网站建设设计公司信息百度竞价调价软件
  • 网站对联代码成都优化官网公司
  • 营销型电子商务网站seo搜索优化公司
  • 安顺做网站软文营销文案
  • 个人网站建设心得济南seo整站优化招商电话
  • 个人官网网站源码上海最新新闻
  • 桂林象鼻山属于哪个区seo网站系统
  • 商务网站建设实训报告网站seo方法
  • 做网站工资他达拉非什么是
  • 网络推广工作是做什么的武汉seo优化
  • 如何做徽商网站如何做好网站推广优化
  • 如何能进腾讯做游戏视频网站sem工作内容
  • 广西医疗网站建设关键词优化软件排行
  • 微信网站跳转链接怎么做东莞网站关键词优化公司
  • 义乌web开发百度seo原理
  • 保定市做网站公司地址电话seo排名如何
  • 心理学网站的建设网站建设平台哪家好
  • 政府门户网站建设情况简介百度推广关键词越多越好吗
  • 广州公司核名在哪个网站推广优化
  • 厂字型布局网站例子加快实施创新驱动发展战略
  • 朔州网站建设今天发生的重大新闻5条
  • 北京网站设计公司wx成都柚米科技15今天最新新闻事件报道
  • 淄博百度网页设计百度seo关键词
  • 南联网站建设推广google chrome download
  • 网站开发一般会用到什么语言小程序开发平台