When do we have to use typecasting and anonymous classes in real time project? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

When do we have to use typecasting and anonymous classes in real time project?

22nd Jun 2017, 9:11 AM
Sangay Wangmo
Sangay Wangmo - avatar
1 Réponse
0
Most Common example of type casting in Java is getting a random number. Since the method Math.random() Returns a values of the type long but normally we work with an int we have to casting it like this: int x=(int) Math.random(); And getting random numbers is very Common
14th Jul 2017, 2:23 PM
ein siedler
ein siedler - avatar