当前位置: 技术问答>java相关
String的最大允许长度是多少?
来源: 互联网 发布时间:2015-04-11
本文导语: 是否没有限制? | Strings are represented as character array. Therefore, theoretical limit of String length is java.lang.Integer.MAX_VALUE. However, in most machines you will run out of memory before you could create s...
是否没有限制?
|
Strings are represented as character array. Therefore, theoretical limit of String length is java.lang.Integer.MAX_VALUE. However, in most machines you will run out of memory before you could create such a big String.
I use java -Xms256m -Xmx384m MaxStringLength to run the following code successfully. :)
public class MaxStringLength {
public static void main(String args[]) {
int len = Integer.MAX_VALUE/30;
char ch[] = new char[len];
for(int i = 0; i
I use java -Xms256m -Xmx384m MaxStringLength to run the following code successfully. :)
public class MaxStringLength {
public static void main(String args[]) {
int len = Integer.MAX_VALUE/30;
char ch[] = new char[len];
for(int i = 0; i