How do I get an instance of Class
in Scala? In Java, I can do this:
Class<String> stringClass = String.class;
What would be the equivalent in Scala?
How do I get an instance of Class
in Scala? In Java, I can do this:
Class<String> stringClass = String.class;
What would be the equivalent in Scala?
There is a method classOf
at the AnyRef
level:
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