Creating a multi-dimensional array

I'm sure this is something trivial, but I can't seem to create a multi-dimensional array. The scala.Array class has constructors for them, but it won't let me do it:

scala> val data = new Array[Float](4, 4) 
<console>:4: error: too many arguments for array constructor: found 2 but array has only 1 dimension(s)
       val data = new Array[Float](4, 4)
                  ^

What am I doing wrong?

Re: Creating a multi-dimensional array

You can do it like this:

val data = new Array[Array[Float]](4, 4)

Robert Kosara-2 wrote:
>
> I'm sure this is something trivial, but I can't seem to create a
> multi-dimensional array. The scala.Array class has constructors for them,
> but it won't let me do it:
>
> scala> val data = new Array[Float](4, 4)
> :4: error: too many arguments for array constructor: found 2 but
> array has only 1 dimension(s)
> val data = new Array[Float](4, 4)
> ^
>
> What am I doing wrong?
>
>

-----
My scala solutions for http://projecteuler.net/ Project Euler problems:
http://eastsun.javaeye.com/category/34059 Click here

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland