Reputation: 64207
I need to pass a 2-dimensional Java array of primitive values defined as
int myArray[][] = {{ 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 }};
in Java terms into a Java library function from a Scala application.
How to define such an object in Scala?
Upvotes: 0
Views: 150
Reputation: 3724
The equivalent Scala to your Java is:
val myArray = Array(Array(1, 2), Array(3, 4), Array(5, 6), Array(7, 8))
Scala uses the exact same Array that Java does. An Array in Scala appears to have additional functionality because arrays are implicitly wrapped by WrappedArray.
For much more, see this answer.
Upvotes: 5