java explicit array declaration

h‮sptt‬://www.lautturi.com
java explicit array declaration

In Java, you can explicitly declare an array by using the new operator to create an array object and specifying the type and size of the array.

Here's an example of how to explicitly declare an array in Java:

int[] array = new int[5];

In this example, an array of int elements with a size of 5 is explicitly declared. The array is created using the new operator and the int[] type, and the size of the array is specified in square brackets.

You can also use the new operator to explicitly declare and initialize an array in Java:

int[] array = new int[] {1, 2, 3, 4, 5};

In this example, an array of int elements with a size of 5 is explicitly declared and initialized with the values 1, 2, 3, 4, and 5.

You can use the explicit array declaration syntax to declare and initialize arrays of any type in Java. Just specify the type of the elements in the array and the size or initial values of the array using the new operator.

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