A
A
artshelom2018-09-14 23:56:41
Java
artshelom, 2018-09-14 23:56:41

Is it possible to increase the string capacity?

Is it possible to increase the capacity of string (I don't think so) or are there more accommodating types?
The compiler throws an error: error: constant string too long

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
illuzor, 2018-09-15
@artshelom

This is not a string length limit, but a string variable length limit on initialization, which is 2^16.
You can break a long string into pieces and assemble the desired string from them:

String str1 = "...";
String str2 = "...";
String str3 = "...";

String myString = str1 + str2 + str3;

But it's better to put this line in resources or in an external file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question