Is there a maximum size to char[]?

Tags:



IN JAVA

Is there a maximum size of char[]? Can I have a char[5,000,000]?

Is array in java composed of contiguous memory blocks?

Answer

Since the index is int based the maximum size of an array should be Integer.MAX_VALUE

Obviously the other limit is the amount of memory available to your application 🙂



Source: stackoverflow