Previous posts: Java 8, Java 9, Java 10.
Java 11 has been released a few days ago. This post lists some improvements in this version that are useful for competitive programming.
- New
String
methods:String.strip()
,String.stripLeading()
,String.stripTrailing()
,String.isBlank()
andString.lines()
can help with parsing, whileString.repeat()
can be used to generate output. StringBuilder
andStringBuffer
instances are nowComparable
. Also,CharSequence.compare()
can be used to compareString
,StringBuilder
andStringBuffer
values without conversion.- Null streams:
InputStream.nullInputStream()
,OutputStream.nullOutputStream()
,Reader.nullReader()
andWriter.nullWriter()
might be useful for testing. - It is now possible to run source files directly:
java Solution.java
.
As before, if you find any other relevant enhancements, please post them here.