DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Expected Features of Java 11

Expected Features of Java 11

Are you ready for Java 11? Check out this post on the expected features for Java 11, including new string and files utility methods.

Gowtham Girithar Srirangasamy user avatar by
Gowtham Girithar Srirangasamy
·
Jul. 30, 18 · Java Zone · Presentation
Like (22)
Save
Tweet
79.16K Views

Join the DZone community and get the full member experience.

Join For Free

In Java 10, the main thing we noticed was the local variable type inference, which helped us a lot. In this article, we are going to discuss a few features that are all expected to be released as part of JDK 11.

1. JDK11 New String Methods

There are a few methods that have been added as part of JDK 11 and helps developers to minimize coding efforts. The methods are listed below with an example.

strip() , stripLeading() , stripTrailing()

The strip() method is used to remove the leading and trailing whitespace. It is helpful to remove the white space from the beginning and end of a string.

 stripLeading()method is used to remove the white space from the beginning of a string.

 stripTrailing()method is used to remove the white space from the end of a string.

Image title

isBlank()

This method returns true if the string is empty or contains only white spaces; otherwise, it returns false.

Image title

lines()

This method is used to return the stream of strings that are partitioned by line terminators. The lines in the stream are in the order in which they occur in the string. This method is more performant compared to the methods we are using currently.

Image title

repeat(n)

This method will return the concatenated string, and the number of times it will concatenate is dependant upon the count that we supply as an argument to this method.

Image title

Files Utility Methods

writeString

This method is used to write the contents to a file. Characters are encoded into bytes using the specified charset, and the default value is a UTF-8 charset.

readString

This method will read all contents from a file into a string, decoding from bytes to characters using the UTF-8 charset. The method also ensures that the file is closed when all content has been read or an I/O error, or other runtime exception, is thrown.

Image title

isSameFile

This method is used for tests if two paths locate the same file or not. This method returns true if two path objects are equal without even checking the file existence.

Image title

3. Pattern With Predicate Utility Methods

MatchPredicate

We had the asPredicate() method as part of JDK 8, which will create a predicate if this pattern is found in a given string. In JDK 11, the new method asMatchPredicate() has been introduced and will create a predicate if this pattern matches a given input string.

Image title

4. Predicate not(Predicate<? super T> target)

This method is used to return a predicate, which is the negation of supplied predicate.

5.Local-Variable Syntax for Lambda Parameters

JDK 11 allows var to be used when declaring the formal parameters of implicitly typed lambda expressions. 

Image title

6. Methods Removed From Thread Class

 destroy()and  stop(Throwable obj)methods of Thread classes are removed in JDK 11. Since JDK 8, the destroy() method has never done anything except throwing the  NoSuchMethodError. The stop(Throwable) method hasn't done anything except throwing the  UnsupportedOperationException.

7.Optional.isEmpty

This method is used to return true if the value is not present, and, otherwise, it returns false.

Image title

8. TimeUnit convert(Duration duration) 

This method is used to convert the given time duration to this unit. This method differs from Duration.toNanos() in that it does not throw the ArithmeticException on numeric overflow.

Image title

9. Epsilon Garbage Collector

This GC handles memory allocation but does not implement any actual memory reclamation mechanism. Once the available Java heap is exhausted, the JVM will shut down. For more details, please refer to JEP 318: Epsilon: A No-Op Garbage Collector.

10. Remove the Java EE and CORBA Modules

JDK 11 removed the Java EE and CORBA modules from the Java SE Platform and the JDK. These modules were deprecated as part of Java SE 9, with the declared intent to remove them in a future release.

Java (programming language)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Role of Development Team in an Agile Environment
  • Applying Kappa Architecture to Make Data Available Where It Matters
  • How to Test JavaScript Code in a Browser
  • How to Utilize Python Machine Learning Models

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo