java empty array

https:/‮w/‬ww.lautturi.com
java empty array

To create an empty array in Java, you can use the new operator and specify the type and size of the array.

Here's an example of how to create an empty array of integers in Java:

int[] array = new int[5];

This example creates an array of integers with a size of 5, and assigns it to the array variable. The array is initially empty, with all of its elements set to the default value for the integer type (0).

You can use a similar approach to create an empty array of any type in Java. Just specify the type of the array elements instead of int, and the size of the array in square brackets.

Here's an example of how to create an empty array of strings in Java:

String[] array = new String[10];

This example creates an array of strings with a size of 10, and assigns it to the array variable. The array is initially empty, with all of its elements set to null.

Created Time:2017-11-03 15:57:12  Author:lautturi