String CharAt Method Using Long

I want to find a character in a specific position on a very large line. However, I cannot use the charAt() method because the range exceeds the value for int. Do you have such a setting?

+8
java
source share
3 answers

In Java, strings have character array support. The theoretical size of the array is limited by the maximum int value, so it is impossible to create a string with more than 2 characters 31 -1.

To overcome this problem, you can create your own string class that uses multiple arrays or strings as storage.

+13
source share

Take only a shorter substring from a large string and get access to the corresponding position?

0
source share

Since String is internally represented by an array of characters, its maximum length cannot be greater than the size of int. Therefore, in the first place, you cannot have a String exceeding the range of int.

0
source share

All Articles