java功能模块_Java 14功能

本文介绍了Java 14的主要特性,包括开关表达式、instanceof的模式匹配(预览)、有用的NullPointerExceptions、记录(预览)以及文本块(预览)。详细讲解了每个特性在Java开发中的应用和变化,例如记录的引用字段值可以被修改,记录可以实现接口等。文章还指导了如何在Mac OS上安装Java 14,并提供了示例代码展示新特性的使用。
摘要由CSDN通过智能技术生成

java功能模块

Keeping up with the six-month cycle tradition, after the release of Java 13 on September 17, 2019, Java 14, another non-LTS version is scheduled to release on March 17, 2020.

遵循六个月的周期传统,在2019年9月17日发布Java 13 Java 14之后,计划在2020年3月17日发布另一个非LTS版本。

Java 14功能 (Java 14 Features)

Here’s the list of Java 14 features:

以下是Java 14功能的列表:

  • Switch Expressions (Standard) – JEP 361

    开关表达式(标准)– JEP 361
  • Pattern Matching for instanceof (Preview) – JEP 305

    instanceof的模式匹配(预览)– JEP 305
  • Helpful NullPointerExceptions – JEP 358

    有用的NullPointerExceptions – JEP 358
  • Records (Preview) – JEP 359

    记录(预览)– JEP 359
  • Text Blocks (Second Preview) – JEP 368

    文本块(第二预览)– JEP 368
  • Packaging Tool (Incubator) – JEP 343

    包装工具(培养箱)– JEP 343
  • NUMA-Aware Memory Allocation for G1 – JEP 345

    G1的NUMA感知内存分配– JEP 345
  • JFR Event Streaming – JEP 349

    JFR事件流– JEP 349
  • Non-Volatile Mapped Byte Buffers – JEP 352

    非易失性映射字节缓冲区– JEP 352
  • ZGC on macOS – JEP 364

    在macOS上使用ZGC – JEP 364
  • ZGC on Windows – JEP 365

    Windows上的ZGC – JEP 365
  • Foreign-Memory Access API (Incubator) – JEP 370

    外部存储器访问API(孵化器)– JEP 370

Mac OS上的Java 14安装设置 (Java 14 Installation Setup on Mac OS)

  • To get started with Java 14, download the JDK from here.

    要开始使用Java 14,请从此处下载JDK。
  • Copy and extract the tar file in the /Library/Java/JavaVirtualMachines as shown below:

    复制/解压缩tar文件到/Library/Java/JavaVirtualMachines ,如下所示:

$ cd /Library/Java/JavaVirtualMachines

$ sudo cp ~/Downloads/openjdk-14_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines

$ sudo tar xzf openjdk-14_osx-x64_bin.tar.gz

$ sudo rm openjdk-14_osx-x64_bin.tar.gz

Once that’s done, open the bash_profile using any text editor. I’m using vim ~/.bash_profile. Set the path of Java14 to JAVA_HOME, save changes and do a source ~/.bash_profile to reflect the changes.

完成后,使用任何文本编辑器打开bash_profile 。 我正在使用vim ~/.bash_profile 。 将Java14的路径设置为JAVA_HOME,保存更改并执行source ~/.bash_profile以反映更改。


export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home

Finally, you’re ready to compile and run programs using Java 14. We’ll be using JShell, an interactive REPL command-line tool for quickly testing the new Java 14 features.

最后,您准备使用Java 14编译和运行程序。我们将使用JShell (一种交互式REPL命令行工具),用于快速测试Java 14的新功能。

It’s important to note that many features released in Java 14 are in preview. This means that though they’re fully working right now, things may be modified in the future. Some could be made a standard or simply removed in the next release cycles. In order to test preview features, you need to explicitly set --enable-preview when running the JShell or Java Progr

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值