How many characters can a Java String have?

后端 未结 7 1941
暗喜
暗喜 2020-11-22 06:56

I\'m trying The Next Palindrome problem from Sphere Online Judge (SPOJ) where I need to find a palindrome for a integer of up to a million digits. I thought about using Java

7条回答
  •  粉色の甜心
    2020-11-22 07:09

    Java9 uses byte[] to store String.value, so you can only get about 1GB Strings in Java9. Java8 on the other hand can have 2GB Strings.

    By character I mean "char"s, some character is not representable in BMP(like some of the emojis), so it will take more(currently 2) chars.

提交回复
热议问题