In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "JDK15 new features introduction," interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "JDK15 New Features Introduction"!
1. Added isEmpty default method to CharSequence Defines isEmpty as the default method for testing whether a character sequence is empty, CharSequence::isEmpty can be used as a method reference. The implemented class java.lang.CharSequence and another interface that defines the isEmpty method should be aware of this because they may need to be modified to override the isEmpty method.
Support Unicode 13.0 This release upgrades Unicode support to 13.0, including: java.lang.Characterist13.0 level, which adds 13.0 5930 characters for a total of 143859 character classes supporting Unicode character databases. These additions include four new scripts, for a total of 154 scripts, and 55 new emoji characters. 3. TreeMap New Method
TreeMap re-implements overwhelming e.g. putIfAbsent, computeIfAbsent, computeIfPresent, compute, merage
For example, putIfAbsent is equivalent to the following:
default V putIfAbsent(K key, V value) V v = map.get(key); if (v == null){ v = map.put(key, value); } return v;4, text block (final version)
Advantages: Simplifies the task of writing Java programs while avoiding escape sequences that are common; enhances readability of strings representing code written in non-Java languages in Java programs.
String html = """
Hello, world
""";String query = """ SELECT `EMP_ID`, `LAST_NAME` FROM `EMPLOYEE_TB` WHERE `CITY` = 'INDIANAPOLIS' ORDER BY `EMP_ID`, `LAST_NAME`; "";5, hidden class
Many language implementations built on JVMs rely on dynamic class generation for flexibility and efficiency.
Details can be found in JEP371
6. GC recovery period
Elimination-XXUseAdaptiveGDBound
Improved serialization, IO When you set a serialization filter using the java.io.ObjectInputStream.setObjectInputFilter method, you must call it before reading any objects from the stream. If readObject or the readUnshared method is called, the setObjectInputFilter method throws an IllegalStateException. 8. Optimize substring processing, String.substring In some cases, String.substring returns "", but when the substring length is zero, it can be improved in all cases.
The previous logic is to return "", need to add a new address, but currently null, as follows
public static String stripLeading(byte[] value) { int left = indexOfNonWhitespace(value); if (left == value.length) { return ""; } return (left != 0) ? newString(value, left, value.length - left) : null;}9. Currency grouping separators are supported The DecimalFormat / DecimalFormatSymbols class can now handle grouping delimiters for currency values. For example, the currency grouping delimiter for the German language used in Austria (de-AT locale) is ". ", whereas in other German-language environments the currency grouping separator is". "。10, time Overrides localized values with default values The java.time.format.DateTimeFormatter.localizedBy(Locale) method now takes default locale values, such as locale parameters specified by Chronology and/or DecimalStyle.
For example, in previous JDK releases:
jshell> DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .localizedBy(Locale.forLanguageTag("fa")) .format(LocalDate.now())$3 ==> "جمعه 1 مهٔ 2020"
Numbers are Arabic (Spanish) numbers, in JDK 15:
jshell> DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL) .localizedBy(Locale.forLanguageTag("fa")) .format(LocalDate.now())$3 ==> "جمعه ۱ مهٔ ۲۰۲۰"
These numbers use extended Arabic-Indian numerals because it is the default numbering system for Persian locales.
11、time ValueRange.of ValueRange.of (long min, long maxSmallest, long maxLargest), throws an exception if the minimum is greater than the minimum maximum. However, exceptions occur only if the minimum is greater than the maximum. 12. Performance improvements InflaterOutputStream.write InflaterOutputStream(OutputStream out, Inflater infl, int bufLen) allows you to specify the decompressor and buffer size to use. InflaterOutputStream.write(byte[] b, int off, int len) is writing data using a buffer size of up to 512 bytes. Starting with JDK 15, buffer sizes specified by InflaterOutputStream(OutputStream out, Inflater infl,int bufLen) will be used in calls to InflaterOutputStream.write(byte[] b,int off, int len). If the buffer size is not specified when the InflaterOutputStream constructor is called, it defaults to 512 bytes. 13. Better Listing of Arrays The preferred way to copy a collection is to use the Copy Constructor. For example, to copy a collection into a new ArrayList, you can write new ArrayList(collection). In some cases, additional temporary copies may be made, and if the collection to be copied is very large, the application should (be aware of/monitor) the amount of resources required to make the copy. GC: G1 Optimization
Improvements to G1 heap region size
The default heap region size calculation has been changed to return larger regions by default. The calculation still targets 2048 zones, but two changes have occurred that improve startup and runtime performance Consider only the maximum heap size. The old calculation also takes into account the initial heap size, but this can produce unexpected behavior when the heap size is not set. Region sizes are rounded to the nearest power of 2 instead of decreasing. In cases where the maximum heap size is not a power of 2, this returns a larger region size. 15. ZGC is a scalable low-latency garbage collector Z Garbage Collector (ZGC) is now available for production use and is no longer marked as an experimental feature. Enable ZGC by using the-XX:+UseZGC command-line option 16, instanceof pattern matching (second preview)
Provides pattern matching to enhance Java programming language instanceof
if (obj instanceof String s) { // can use s here } else { //can't use s here }17. Record (second preview version)@Data@AllArgsConstructorclass Group {//group name private String name;//Number of people private int nums;}
Use it instead of constructor, equal method, toString method, hashCode method
Point(String name,int nums){}
A new type declaration in Java. Like enum, record is a restricted form of a class. Declare its representation and submit APIs that match that representation. Records give up the freedom classes usually enjoy: the ability to separate APIs from presentation. In return, the record gains a great deal of simplicity.
At this point, I believe everyone has a deeper understanding of "JDK15 new features introduction", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.