How many characters can a Java String have?

后端 未结 7 2148
暗喜
暗喜 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

    I believe they can be up to 2^31-1 characters, as they are held by an internal array, and arrays are indexed by integers in Java.

提交回复
热议问题