String's Maximum length in Java - calling length() method -
My question is very basic, but I did not find any answer on Google search.
Java , length () method call
length () as a string as char [] ; Considering the method of class one int , the maximum length to be returned by the method, which is 2 ^ 31 - 1 (or approximately 2 billion.)
In terms of the length and sequencing of arrays , (E.g. char [] , which is probably the way internal data representation has been applied to string s), says that:
The variable present in an array has no name; Instead, those array references are used by expressions that use the non-integer integer index values. These variables are called the component of the array. If an array contains the
ncomponent, then we say thatnof the array Length is ; Elements of the array are referred to by using the integer index from0ton - 1, inclusive.
In addition, indexing should be according to int values, as outlined below:
Code> int values should be indexed by;
Therefore, it seems that the limit is actually 2 ^ 31 - 1 , because it is a non-primary int The maximum value is.
However, there are probably other limitations, such as the maximum allocated size for the array.
Comments
Post a Comment