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.
But online judge systems don't allow Java 11, right? The information you provided is still useful.
Just wondering. For example, I have these two submissions: https://mirror.codeforces.com/contest/1110/submission/74875822 https://mirror.codeforces.com/contest/1110/submission/74875845
There is dfs with about 500*1000 nodes in this problem (so there can be a long chain). I have Runtime Error because of this. So I decided to set heap size to 1<<27. The surprise for me is that Java 8 solution passes, while the same Java 11 solution does not. And it seems that Java 11 even eats twice more memory. Can you explain the reasons, or maybe refer me to some resources about this, please?