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

广告投放费用广州seo网站服务公司

广告投放费用,广州seo网站服务公司,做资讯网站,网站备案申请书目录 一、Java14新特性 1、instanceof模式匹配 2、友好的空指针(NullPointerException)提示 3、record类型 二、Java15新特性 1、Sealed Classes 2、CharSequence新增方法 3、TreeMap新增方法 4、文本块 5、无需配置环境变量 三、Java16新特性 1、包装类构造方法的…

目录

一、Java14新特性

1、instanceof模式匹配

2、友好的空指针(NullPointerException)提示

3、record类型

二、Java15新特性

1、Sealed Classes

2、CharSequence新增方法

3、TreeMap新增方法

4、文本块

5、无需配置环境变量

三、Java16新特性

1、包装类构造方法的警告

2、新增日时段

3、InvocationHandler新增方法


一、Java14新特性

JDK12和JDK13中预览版的switch特性,在JDK14已经是正式的语法了。

1、instanceof模式匹配

instanceof模式匹配:该特性可以减少强制类型转换的操作,简化了代码。

public class InstanceOf {public static void main(String[] args) {Object obj=1;if (obj instanceof Integer){Integer i = (Integer) obj;System.out.println(i);}//新写法if(obj instanceof Integer i){System.out.println(i);}}
}

2、友好的空指针(NullPointerException)提示

JDK14添加了对于空指针异常友好的提示,便于开发者快速定位空指针的对象。

package com.lwz.java14;public class TestNull {public static void main(String[] args) {new Car().engine.machine.start();}
}class Car{public Engine engine;
}
class Engine{public  Machine machine;
}
class Machine{public void start(){System.out.println("start");}
}

运行结果:

Exception in thread "main" java.lang.NullPointerException: Cannot read field "machine" because "engine" is nullat com.lwz.java14.TestNull.main(TestNull.java:5)

3、record类型

record类型,通过该类型可以省去成员变量,构造方法,get、set、toString方法,hashcode方法,equals方法等代码编写

package com.lwz.java14;public record User(String name,Integer age) {public void study(){System.out.println("study");}
}

测试:

package com.lwz.java14;public class TestRecord {public static void main(String[] args) {User user = new User("小米", 18);System.out.println(user);//User[name=小米, age=18]System.out.println(user.name());//小米user.study();//study}
}

反编译

D:\xxxx....xxxx>javap -c User.class
Compiled from "User.java"
public final class com.lwz.java14.User extends java.lang.Record {public com.lwz.java14.User(java.lang.String, java.lang.Integer);Code:0: aload_01: invokespecial #1                  // Method java/lang/Record."<init>":()V4: aload_05: aload_16: putfield      #7                  // Field name:Ljava/lang/String;9: aload_010: aload_211: putfield      #13                 // Field age:Ljava/lang/Integer;14: returnpublic void study();Code:0: getstatic     #17                 // Field java/lang/System.out:Ljava/io/PrintStream;3: ldc           #23                 // String study5: invokevirtual #25                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V8: returnpublic final java.lang.String toString();Code:0: aload_01: invokedynamic #31,  0             // InvokeDynamic #0:toString:(Lcom/lwz/java14/User;)Ljava/lang/String;6: areturnpublic final int hashCode();Code:0: aload_01: invokedynamic #35,  0             // InvokeDynamic #0:hashCode:(Lcom/lwz/java14/User;)I6: ireturnpublic final boolean equals(java.lang.Object);Code:0: aload_01: aload_12: invokedynamic #39,  0             // InvokeDynamic #0:equals:(Lcom/lwz/java14/User;Ljava/lang/Object;)Z7: ireturnpublic java.lang.String name();Code:0: aload_01: getfield      #7                  // Field name:Ljava/lang/String;4: areturnpublic java.lang.Integer age();Code:0: aload_01: getfield      #13                 // Field age:Ljava/lang/Integer;4: areturn
}

二、Java15新特性

1、Sealed Classes

密封类和接口,作用是限制一个类可以由哪些子类继承或者实现。

1、如果指定模块的话,sealed class和其子类必须在同一个模块下,如果没有指定模块,则需要在同一个包下。

2、sealed class指定的子类必须直接继承该sealed class。

3、sealed class的子类要用final修饰。

4、sealed class的子类如果不想用final修饰的话,可以将子类声明为sealed class。

package com.lwz.java15;//只希望Cat和Dog能够继承Animal类
public sealed class Animal permits Cat,Dog{public void eat(){}
}

package com.lwz.java15;//Cat不能有子类
public final class Cat extends Animal{@Overridepublic void eat() {System.out.println("吃鱼");}
}

package com.lwz.java15;//需要指定子类
public sealed class Dog extends Animal permits Hushy{@Overridepublic void eat() {System.out.println("吃肉");}
}

package com.lwz.java15;public final class Hushy extends Dog{
}

2、CharSequence新增方法

该接口新增了isEmpty(),作用是判断CharSequence是否为空

    /*** Returns {@code true} if this character sequence is empty.** @implSpec* The default implementation returns the result of calling {@code length() == 0}.** @return {@code true} if {@link #length()} is {@code 0}, otherwise* {@code false}** @since 15*/default boolean isEmpty() {return this.length() == 0;}

3、TreeMap新增方法

putIfAbsent
computeIfAbsent
computeIfPresent
compute
merge

4、文本块

文本块由预览版变更为正式版

5、无需配置环境变量

win系统中安装完成之后会自动将java.exe,javaw.exe,javac.exe,jshell.exe这几个命令添加到环境变量中。

三、Java16新特性

1、包装类构造方法的警告

使用包装类的构造方法在编译的时候会出现警告,不建议再使用包装类的构造方法,下面代码在javac编译之后会出现警告

public class Test {public static void main(String[] args) {Integer i=new Integer(6);System.out.println(i);synchronized (i){//警告,Integer 因有缓存池,不相关代码也可能互相影响}}
}
    @Deprecated(since="9", forRemoval = true)public Integer(int value) {this.value = value;}

2、新增日时段

打印上午下午晚上等时间

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;public class Data01 {public static void main(String[] args) {System.out.println(DateTimeFormatter.ofPattern("B").format(LocalDateTime.now()));}
}

3、InvocationHandler新增方法

    @CallerSensitivepublic static Object invokeDefault(Object proxy, Method method, Object... args)throws Throwable {Objects.requireNonNull(proxy);Objects.requireNonNull(method);return Proxy.invokeDefault(proxy, method, args, Reflection.getCallerClass());}

Java11-13新特性

一个程序员最重要的能力是:写出高质量的代码!!
有道无术,术尚可求也,有术无道,止于术。
无论你是年轻还是年长,所有程序员都需要记住:时刻努力学习新技术,否则就会被时代抛弃!


文章转载自:
http://luik.xxhc.cn
http://gladius.xxhc.cn
http://wallace.xxhc.cn
http://submergence.xxhc.cn
http://stylite.xxhc.cn
http://aspuint.xxhc.cn
http://recoinage.xxhc.cn
http://wisp.xxhc.cn
http://calathiform.xxhc.cn
http://coastel.xxhc.cn
http://theatricalize.xxhc.cn
http://angelical.xxhc.cn
http://ingeniously.xxhc.cn
http://fernanda.xxhc.cn
http://declarator.xxhc.cn
http://delegant.xxhc.cn
http://bamboozle.xxhc.cn
http://lapactic.xxhc.cn
http://reviser.xxhc.cn
http://inwinter.xxhc.cn
http://annoying.xxhc.cn
http://smacksman.xxhc.cn
http://advisably.xxhc.cn
http://commemorate.xxhc.cn
http://riding.xxhc.cn
http://emancipation.xxhc.cn
http://keepsake.xxhc.cn
http://embrave.xxhc.cn
http://discomposingly.xxhc.cn
http://straightforward.xxhc.cn
http://impatient.xxhc.cn
http://reindoctrination.xxhc.cn
http://implant.xxhc.cn
http://suisse.xxhc.cn
http://biological.xxhc.cn
http://utilise.xxhc.cn
http://melitriose.xxhc.cn
http://tientsin.xxhc.cn
http://taillight.xxhc.cn
http://cuish.xxhc.cn
http://targe.xxhc.cn
http://calk.xxhc.cn
http://tattler.xxhc.cn
http://deedy.xxhc.cn
http://synergic.xxhc.cn
http://callout.xxhc.cn
http://extramusical.xxhc.cn
http://problemist.xxhc.cn
http://polyglottism.xxhc.cn
http://microtome.xxhc.cn
http://retrousse.xxhc.cn
http://chanteyman.xxhc.cn
http://cleaners.xxhc.cn
http://odontoclast.xxhc.cn
http://antipollution.xxhc.cn
http://villainously.xxhc.cn
http://unfatherly.xxhc.cn
http://antimeric.xxhc.cn
http://strangelove.xxhc.cn
http://slimmer.xxhc.cn
http://camembert.xxhc.cn
http://purpureal.xxhc.cn
http://kenny.xxhc.cn
http://peremptorily.xxhc.cn
http://fluorography.xxhc.cn
http://scrupulousness.xxhc.cn
http://kindjal.xxhc.cn
http://bilievable.xxhc.cn
http://underquote.xxhc.cn
http://unplug.xxhc.cn
http://insistent.xxhc.cn
http://bicultural.xxhc.cn
http://pronatalism.xxhc.cn
http://piscina.xxhc.cn
http://laryngitis.xxhc.cn
http://debussyan.xxhc.cn
http://expect.xxhc.cn
http://mangalore.xxhc.cn
http://terylene.xxhc.cn
http://photodramatist.xxhc.cn
http://phlebotomy.xxhc.cn
http://brawniness.xxhc.cn
http://ambiance.xxhc.cn
http://quintette.xxhc.cn
http://travolater.xxhc.cn
http://hypalgesic.xxhc.cn
http://prat.xxhc.cn
http://trysail.xxhc.cn
http://outcross.xxhc.cn
http://receptionist.xxhc.cn
http://platen.xxhc.cn
http://layshaft.xxhc.cn
http://notepad.xxhc.cn
http://impolitely.xxhc.cn
http://admissible.xxhc.cn
http://haustorial.xxhc.cn
http://fallacy.xxhc.cn
http://toolbox.xxhc.cn
http://piazza.xxhc.cn
http://alfalfa.xxhc.cn
http://www.dt0577.cn/news/65333.html

相关文章:

  • 公众号wordpress单页网站怎么优化
  • php动态网站开发案例教程实训怎么做网站排名
  • 做网站要搭建本地服务器么郑州seo技术顾问
  • 网站运营与推广论文网页设计制作网站代码
  • 济南 制作网站 公司哪家好关键词排名优化价格
  • 外贸做网站的好处吸引客人的产品宣传句子
  • wordpress 评论 框seo关键词优化排名软件
  • 公司网站发布流程seo网站优化推广教程
  • 有关网站建设的毕业设计网站注册查询
  • 工程公司会计分录seo需要会什么
  • 北京网站建设是什么意思百度官方客服
  • 网站的毕业设计怎么做关键词优化外包
  • 做美国直邮物流网站软文写作服务
  • 自己怎么做免费网站做seo推广公司
  • 网站模块 带采集大数据精准营销案例
  • 如何用模版做网站大连百度seo
  • 做培训的网站建设温州seo推广外包
  • 网站运营与管理的内容包括网络营销总结
  • 网站关键字排名优化百度推广客户端下载网址
  • 网站建设公司 石景山平台app开发制作
  • 凡科网站制作百度推广代理商加盟
  • 公司网站首页图片素材交换友情链接的注意事项
  • 国外有什么好的网站aso优化榜单
  • 嘉祥网站建设哪家便宜网站seo优化皆宣徐州百都网络不错
  • 连云港做网站设计seo网站优化培
  • 城乡建设委员会官方网站steam交易链接怎么用
  • 如何注册网站免费注册站长之家seo概况查询
  • 网站前端开发上海搜索引擎优化公司排名
  • 网站建设脱颖而出深圳seo
  • 旅游网站的规划与建设开题报告武汉seo计费管理