How can you correctly initialize a 2D array in Java?

Last Updated :
Discuss
Comments

How can you correctly initialize a 2D array in Java?

int[][] arr = new int(3,3);

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

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

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

Share your thoughts in the comments