scalaarray-initialization

Array initializing in Scala


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 ?


Solution

  • scala> val arr = Array("Hello","World")
    arr: Array[java.lang.String] = Array(Hello, World)