Блог пользователя eatmore

Автор eatmore, история, 6 лет назад, По-английски

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.

  • Проголосовать: нравится
  • +45
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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

»
5 лет назад, # |
Rev. 2   Проголосовать: нравится -10 Проголосовать: не нравится

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?