You cannot make an empty array and then let it grow dynamically whenever the user enters a number in the command line. You should read the numbers and put them in an ArrayList instead. An ArrayList does not require a initial size and does grow dynamically. Something like this:

public void main(String[] args) {
    ArrayList<Integer> numbers = new ArrayList<Integer>();
    BufferedReader console = 
            new BufferedReader(new InputStreamReader(System.in));
    while(true) {
        String word = console.readLine();
        if (word.equalsIgnoreCase("end") {
            break;
        } else {
            numbers.add(Integer.parseInt(word);
        }
    }

Ofcourse you won't use while(true)and you won't put this in main, but it's just for the sake of the example

Answer from JNevens on Stack Overflow
๐ŸŒ
MathWorks
mathworks.com โ€บ matlab โ€บ language fundamentals โ€บ matrices and arrays
Empty Arrays - MATLAB & Simulink
For example, create a 0-by-5 matrix and a 3-by-0-by-5 array. ... The square brackets, zeros, and ones create empty numeric arrays of the default double data type. To create empty arrays that work with text as data, use the strings function. This function creates a string array of any specified ...
People also ask

How do I create an empty array in Python?
Use an empty list: items = []. For typed numbers use array("d") from the array module, and for math use NumPy's np.array([]).
๐ŸŒ
pythonguides.com
pythonguides.com โ€บ create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
How do I check if an array is empty?
For a list, if not items:. For a NumPy array, use arr.size == 0, because the truth value of an empty NumPy array raises ValueError.
๐ŸŒ
pythonguides.com
pythonguides.com โ€บ create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
How do I declare an empty array of size n in Python?
Python doesn't declare sizes, but [None] * n or [0] * n gives you n slots to fill by index. With NumPy, np.zeros(n) does the same.
๐ŸŒ
pythonguides.com
pythonguides.com โ€บ create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-initialize-empty-array-of-given-length
Python - Initialize empty array of given length - GeeksforGeeks
In this method, we can use the repeat() function from the itertools module to create a new iterator that returns the same value a certain number of times. This can be used to create an empty array of a specific size by providing a value of None ...
Published: July 12, 2025
๐ŸŒ
Python Guides
pythonguides.com โ€บ create-an-empty-array-in-python
Python Empty Array: Create, Declare, Size N and NumPy
January 12, 2026 - Create an empty array in Python with [], declare one of size n, avoid the [[]] * n trap, use the array module or NumPy, and check if an array is empty.
๐ŸŒ
Code Maze
code-maze.com โ€บ home โ€บ c# empty array: declare, create and initialize
C# Empty Array: Declare, Create and Initialize - Code Maze
1 month ago - On C# 12 or later, write [] where the target type is obvious and Array.Empty<T>() where it is not. Both compile to the same thing, so the choice between them is about reading, not about speed. When the collection has to grow after we create it, start with an empty List<T> instead of an array.
Find elsewhere
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ third party โ€บ numpy โ€บ empty()
Python Numpy empty() - Create Empty Array | Vultr Docs
November 18, 2024 - Create an array using the shape tuple. ... Here, the empty() function creates a 2x3 array.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ scala collections โ€บ create an empty array in scala
Create an Empty Array in Scala | Baeldung on Scala
March 18, 2024 - Array.empty is a more readable way to create an empty array and is very clear about its intent.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.5 Manual
In this case, it ensures the creation of an array object compatible with that passed in via this argument. New in version 1.20.0. ... Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None. ... Return an empty array with shape and type of input.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
NumPy: Create an empty array (np.empty, np.empty_like) | note.nkmk.me
January 22, 2024 - To create an empty array with the same shape and data type (dtype) as an existing array, use np.empty_like().
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ reference โ€บ generated โ€บ numpy.empty.html
numpy.empty โ€” NumPy v2.6.dev0 Manual
For reproducible behavior, be sure to set each element of the array before reading. ... Try it in your browser! >>> import numpy as np >>> np.empty([2, 2]) array([[ -9.74499359e+001, 6.69583040e-309], [ 2.13182611e-314, 3.06959433e-309]]) #uninitialized
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ create-empty-array-of-a-given-size-in-javascript
Create empty array of a given size in JavaScript
March 15, 2026 - Use new Array(size) for basic empty arrays, or Array.from({length: size}) when you need to iterate immediately.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ numpy โ€บ how-to-create-an-empty-and-a-full-numpy-array
How to create an empty and a full NumPy array - GeeksforGeeks
September 19, 2025 - Creating arrays is a basic operation in NumPy. Two commonly used types are: Empty array: This array isnโ€™t initialized with any specific values. Itโ€™s like a blank page, ready to be filled with data later.
๐ŸŒ
Just Academy
justacademy.co โ€บ blog-detail โ€บ how-to-declare-empty-array-in-javascript
How to Declare Empty Array in JavaScript by Roshan Chaturvedi | JustAcademy
April 23, 2024 - 1 - Use the square brackets notation: You can declare an empty array in JavaScript using square brackets as follows: `let emptyArray = [];`. This creates a new array with no elements.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ how-to-initialize-an-empty-array-of-given-length-using-python
How to Initialize an Empty Array of given Length using Python
March 27, 2026 - The multiplication operator repeats elements to create an array of specified length ? length = 5 arr = [None] * length print("Empty array using multiplication operator:") print(arr) print("Length:", len(arr))
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ best-way-to-initialize-empty-array-in-php
Best way to initialize empty array in PHP - GeeksforGeeks
July 11, 2025 - Arrays in PHP: Use array() Function to create an array in PHP. There are three types of array supported in PHP: Indexed arrays: Arrays having a numeric index. Associative arrays: Arrays having named keys. Multidimensional arrays: It contains one or more array in particular array. Note: Why it is always good practice to declare an empty array and then push the items to that array?