jeudi 16 mars 2017

what is the advantage of using class.forname() over the new keyword for loading an instance?

Heading ##i know definition. we use class.forname("") when we don't know the type of the class but that's the conundrum here.

If i say: Class.ForName("SomeClass");

So i damn well know the type of "SomeClass". So all compiler does in class.forname("SomeClass") case is does not check whether "SomeClass" exists or not during the Compile time. But it will check it at run time. But is it really the advantage? Can anyone explain this to me with real time scenario?





Aucun commentaire:

Enregistrer un commentaire