Three kinds of assignment methods of JAVA array

Three types of assignment methods for arrays of basic data types

The first assignment method

int[] arr = {
    
    1,2,3};

The second way of assignment

int[] arr2 = new int[]{
    
    1,2,3};

The third way of assignment

int[] arr3 = new int[3];
arr3[0] = 1;
arr3[1] = 2;
arr3[2] = 3;

Guess you like

Origin blog.csdn.net/qq_45783660/article/details/113997898