Aaron Yodaiken
Aaron Yodaiken

Reputation: 19561

scala and java arrays

Is there any difference on Scala 2.9.1:

Array[String]().getClass

and Java 7:

String[].class

?

If so, how would I emulate the Java 7 result in Scala?

Upvotes: 1

Views: 397

Answers (1)

missingfaktor
missingfaktor

Reputation: 92116

String[].class translates to classOf[Array[String]] in Scala.

In Array[String]().getClass, you are creating a string array then invoking its getClass method. ((new String[0]).getClass() in Java.)

Upvotes: 13

Related Questions