You can refer the following code to create 2D array:
class 2D_array
{
public static void main (String args[])
{
int arr[][]=new int[3][3];
System.out.println("Enter the elements");
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[i].length;j++)
{
Scanner sc=new Scanner(System.in);
arr[i][j]=sc.nextInt();
}
}
System.out.println("your array is");
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr[i].length;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println();
}