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

> I know that length () as a string as char [] ;

class = "post-text" itemprop = "text">

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 n component, then we say that n of the array Length is ; Elements of the array are referred to by using the integer index from 0 to n - 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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -