How to allocate an array of type byte with length of N millions in Java

1 Answer

0 votes
public class Main {
    public static void main(String[] args) {
        int size = 10_000_000; // 10 million

        byte[] arr = new byte[size];

        System.out.println(arr.length);
    }
}


/*
run:

10000000

*/

 



answered Jul 1, 2025 by avibootz
...