Linked Questions
94 questions linked to/from Do Java arrays have a maximum size?
7
votes
6
answers
72k
views
Possible Lossy conversion from long to int [duplicate]
I wish to enter one int and another long ex: 1 and 1000000000, and now I wish to create an array of size 1000000000. And then at each index of array, store int val, ex: arr[100000000] = 4.
When I'...
0
votes
1
answer
7k
views
What's the limit of Java 2D array length? [duplicate]
I was doing boundary check of a 2D array which is array[8][LIMIT]; Then I tried several times and found the LIMIT variable should not be larger than 89489404, otherwise there will be an exception like ...
0
votes
1
answer
423
views
How many integers can an array in java and python have? [duplicate]
How many integers can an array in java and python have? And if I want to enter more integers to an array and I reached that limit how to handle this?
-1
votes
1
answer
258
views
How big is the args array in public static void main(String[] args) in java? [duplicate]
When using command line arguments in java I am curious to how big is the args array parameter in main. And if it is varied length how does main know the length?
0
votes
0
answers
186
views
How can I create an array or arraylist which the size is a BigInteger. I need a real big array [duplicate]
I'm trying to calculate all prime numbers of given a limit using the sieve of eratosthenes method. I know how to do that with big numbers as limit, but what if I try a real big number, larger than ...
-1
votes
2
answers
89
views
Compilation error when size of Array of user defined class is long type [duplicate]
when i working on java ,i tried to create an array of Node class . For specifying size i used int before,it worked fine but when i changed to long it is giving me compilation error. plz check the code ...
-2
votes
1
answer
131
views
Why is the output showing error for the value of int? [duplicate]
class lab1{
public static void main(String[] args){
int arr[]= new int[2147483647];
System.out.println(arr.length);
}
}
-1
votes
2
answers
131
views
Instantiating java array with maximum size [duplicate]
I am wondering how to instantiate a long[] array in Java with the greatest possible length. If it is too big, I get a memory error. I need this array to be as big as possible without exceeding the ...
0
votes
0
answers
89
views
Does Java support array size more than 2^31 -1? [duplicate]
I was trying to create a int[] type array in Java with a user input based length. Below is the code for the same :
int[] change = new int[max+1];
When the value of max = 2147483647, the compiler ...
-1
votes
2
answers
74
views
Can we initiliaze a String array of size 1447891223? [duplicate]
I am trying the following code
String[] buffer = new String[1447891223];
Arrays.fill(buffer, "0.0");
The above code gives me java.lang.OutOfMemoryError: Java heap space
Is there any way i could do ...
0
votes
0
answers
25
views
How to create a long array of 4b elements [duplicate]
Long in Java has size 2^63-1. But if I write a code like this, my IDE says Incompatible types: required int but found long.
long [] array = new long[4_000_000_000L];
What is the problem here?
181
votes
4
answers
122k
views
When is each sorting algorithm used? [closed]
What are the use cases when a particular sorting algorithm is preferred over others - merge sort vs QuickSort vs heapsort vs 'intro sort', etc?
Is there a recommended guide in using them based on the ...
47
votes
12
answers
48k
views
Can Java's hashCode produce same value for different strings?
Is it possible to have same hashcode for different strings using java's hashcode function?or if it is possible then what is the % of its possibility?
24
votes
11
answers
19k
views
Java array with more than 4gb elements
I have a big file, it's expected to be around 12 GB. I want to load it all into memory on a beefy 64-bit machine with 16 GB RAM, but I think Java does not support byte arrays that big:
File f = new ...
10
votes
15
answers
42k
views
Making a very large Java array
I'm trying to find a counterexample to the Pólya Conjecture which will be somewhere in the 900 millions. I'm using a very efficient algorithm that doesn't even require any factorization (similar to a ...