此對象是什麼類型的?SCALA:對象類型
class Zad1[A,B](val fst:A, val snd:B) {
override def toString: String = "(" + fst +","+snd+")"
}
object Zad1 {
def main(args: Array[String]): Unit = {
val v = new Zad1[Int, String](1, "2")
println(v)
}
}
我試圖用打印類名:
println(v.getClass) // would print: class $line8.$read$$iw$$iw$Zad1
println(v.getClass.getName) –