Array initializing in Scala

Emil picture Emil · Oct 7, 2010 · Viewed 141.5k times · Source

I'm new to Scala ,just started learning it today.I would like to know how to initialize an array in Scala.

Example Java code

String[] arr = { "Hello", "World" };

What is the equivalent of the above code in Scala ?

Answer

Vasil Remeniuk picture Vasil Remeniuk · Oct 7, 2010
scala> val arr = Array("Hello","World")
arr: Array[java.lang.String] = Array(Hello, World)