T
Timasmith
Hi,
Can I check if a class is an implementation of an interface by name
without instantiating it?
So I can do this:
if (Class.forName("com.company.package.myclass").newInstance()
instanceof MyInterface) {
// class implements interface
}
but it seems create an instance of it by reflection is suboptimal.
Can I do the same thing without calling newInstance()?
thanks
Can I check if a class is an implementation of an interface by name
without instantiating it?
So I can do this:
if (Class.forName("com.company.package.myclass").newInstance()
instanceof MyInterface) {
// class implements interface
}
but it seems create an instance of it by reflection is suboptimal.
Can I do the same thing without calling newInstance()?
thanks