Determining if a java.lang.Class object implements Comparable
If I have a Class clazz object, is it possible to determine if it implements Comparable without calling newInstance() against it?
This is the code I currently have, but I'd like to do the same thing without creating a variable that will immediately be thrown away.
privateboolean implementsComparable(Class clazz)
{
try
{
if (clazz.newInstance()instanceof Comparable)
{
returntrue;
}
}
catch (Exception ex)
{
// @TODO something about NPE's
// ignore all exceptions here
}
returnfalse;
}
Thank you.

