Reputation: 2873
Using the AWT.Transferable, I get an argument "data: Any" which is actually of type java.util.Arrays.ArrayList. How can I cast the "data" explicitly to this type? It seems I do not have any access to the "ArrayList"-Type itself...
Upvotes: 0
Views: 361
Reputation: 297265
This
data match {
case jlist: java.util.List[_] => // I got an java.util.list!
case _ => // oops, unexpected!
}
is type-safe, which doesn't happen to be the case of asInstanceOf
.
Upvotes: 1
Reputation: 134310
Why do you need the class explicitly? Couldn't you use the java.util.List
interface?
data.asInstanceOf[java.util.List[_]]
Note that casting is not encouraged, which is why it looks so awful in Scala!
Upvotes: 1