How I can cast a variable in Scala?

Ads
Ads

How I can cast a variable in Scala?


Java Coder
How I can cast a variable in Scala?
1 Answer(s)      7 months ago
Posted in : Big Data
Ads

Hi,

Trying Big Data and now I want to learn to cast variables.

Thanks

View Answers

November 12, 2017 at 7:21 PM


Hi,

Suppose you have an object of Graphics and you wan to cast it to Graphics2D then you can use following code:

g.asInstanceOf[Graphics2D];

Similarly you can apply this logic to all other classes in SCALA.

Thanks


Ads