What is the Scala equivalent of Java’s ClassName.class?

There is a method classOf in scala.Predef that retrieves the runtime representation of a class type.

val stringClass = classOf[String]

You can use the getClass method to get the class object of an instance at runtime in the same manner as Java

scala> val s = "hello world"
s: String = hello world

scala> s.getClass
res0: Class[_ <: String] = class java.lang.String

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)