从String的源码上看:
public final class String
implements java.io.Serializable, Comparable, CharSequence
{
/** The value is used for character storage. */
private char value[]; /** The offset is the first index of the storage that is used. */
private int offset; /** The count is the number of characters in the String. */
private int count; /** Cache the hash code for the string */
private int hash = 0; /** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = -6849794470754667710L;
......应该可以最大是2^32-1个字符,但是最终就取决于你能提供jvm多少内存了
public final class String
implements java.io.Serializable, Comparable, CharSequence
{
/** The value is used for character storage. */
private char value[]; /** The offset is the first index of the storage that is used. */
private int offset; /** The count is the number of characters in the String. */
private int count; /** Cache the hash code for the string */
private int hash = 0; /** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = -6849794470754667710L;
......应该可以最大是2^32-1个字符,但是最终就取决于你能提供jvm多少内存了
我们都当作没有限制的