To add to what Ricky Clarkson said, it works
scala> "hi".asInstanceOf[java.io.Serializable] res7: java.io.Serializable = hi
but it is not
scala> "hi".asInstanceOf[scala.Serializable] java.lang.ClassCastException: java.lang.String cannot be cast to scala.Serializable ...
Without qualification, Serializable in Scala refers to scala.Serializable . Note that lines in Scala are of type java.lang.String ; they are native to the JVM and are unaware of Scala. According to the API docs , the Scala serializable trait exists for cross-platform compatibility (Java and .NET). If you're only on the JVM, then java.io.Serializable should be enough.
Kipton barros
source share