What is the method for static initialization of a two-dimensional array in Java?

The following syntax can be used to statically initialize a two-dimensional array:

int[][] array = {
    {1, 2, 3},
    {4, 5, 6},
    {7, 8, 9}
};

In this example, the array is a two-dimensional array containing 3 elements (subarrays), each subarray containing 3 integer elements.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds