In Java, will using Class.forName in a cast result in the object being cast to a class or being cast to the cast found. As an example, if you did this
Object a;
String b = "testing";
a = (Class.forName("java.lang.Object")) b;
Would a be an instance of Class or an instance of Object?
Class.forNamereturns aClassinstance. I’m fairly certain your code as quoted doesn’t compile, you’re trying to use a function call as a cast.Update: Just had a thought: If you’re asking how to use a dynamically-loaded class in a cast, you basically can’t. Casting is (mostly) a compile-time thing. Have the dynamically-loaded class implement an interface you can compile into your code and then cast to that, or if you can’t do that, use reflection to access the dynamically-loaded class’ members.