eatmore's blog

By eatmore, history, 6 years ago, In English

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() and String.lines() can help with parsing, while String.repeat() can be used to generate output.
  • StringBuilder and StringBuffer instances are now Comparable. Also, CharSequence.compare() can be used to compare String, StringBuilder and StringBuffer values without conversion.
  • Null streams: InputStream.nullInputStream(), OutputStream.nullOutputStream(), Reader.nullReader() and Writer.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.

  • Vote: I like it
  • +45
  • Vote: I do not like it

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

But online judge systems don't allow Java 11, right? The information you provided is still useful.

»
5 years ago, # |
Rev. 2   Vote: I like it -10 Vote: I do not like it

Just wondering. For example, I have these two submissions: https://codeforces.net/contest/1110/submission/74875822 https://codeforces.net/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?