two dimensional array scala

Sure! Here's an example of how you can create a two-dimensional array in Scala:

// Create a 2D array of integers with 3 rows and 4 columns
val array2D = Array.ofDim[Int](3, 4)

// Assign values to the elements of the array
array2D(0)(0) = 1
array2D(0)(1) = 2
array2D(0)(2) = 3
array2D(0)(3) = 4

array2D(1)(0) = 5
array2D(1)(1) = 6
array2D(1)(2) = 7
array2D(1)(3) = 8

array2D(2)(0) = 9
array2D(2)(1) = 10
array2D(2)(2) = 11
array2D(2)(3) = 12

// Access the elements of the array
val element = array2D(1)(2)

// Print the elements of the array
for (row <- array2D) {
  for (elem <- row) {
    print(elem + " ")
  }
  println()
}

This code creates a 2D array using the Array.ofDim method, which takes the number of rows and columns as parameters. You can assign values to the elements of the array using the indexing syntax array2D(row)(column) = value, where row and column represent the indices of the element you want to assign a value to. You can access the elements of the array in a similar way using the indexing syntax array2D(row)(column). The code also includes an example of how to iterate over the elements of the array using nested for loops.