If you don’t want or cannot use ArrayList, then there is a utility method:
Arrays.copyOf()
that will allow you to specify new size, while preserving the elements.
More Related Contents:
- Java sort 4 arrays into 1 array
- Converting array string to arraylist without nesting it in Java
- Creating a program to file criminal cases and then view them, with new case being allowed to add
- How do I declare and initialize an array in Java?
- How can I concatenate two arrays in Java?
- How to initialize an array in Java?
- Are arrays passed by value or passed by reference in Java? [duplicate]
- JSON Array iteration in Android/Java
- Where is array’s length property defined?
- Java Array Sort descending?
- Java: Reading a file into an array
- How to map a PostgreSQL array with Hibernate
- Finding the second highest number in array
- Java Comparator class to sort arrays
- Why does my sorting loop seem to append an element where it shouldn’t?
- Can an array be used as a HashMap key?
- varargs and the ‘…’ argument
- Converting an array of objects to an array of their primitive types
- Getting the array length of a 2D array in Java
- Deep copy of an object array
- Reversing an Array in Java [duplicate]
- java.net.URL read stream to byte[]
- AssertEquals 2 Lists ignore order
- Split a String at every 3rd comma in Java
- How to get unique items from an array?
- Is it possible to dynamically build a multi-dimensional array in Java?
- Java OutOfMemoryError in reading a large text file
- Why does printing a Java array show a memory location [duplicate]
- How to remove element from an array
- Error of int cannot be dereferenced?