Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if a Java class is abstract?

Is there a way programmitcally to tell if a Java class is abstract? (Other than trying to instantiate and catching the error) Thanks!

like image 825
jim Avatar asked Feb 12 '10 18:02

jim


1 Answers

You can use reflection:

if (Modifier.isAbstract(FooBar.class.getModifiers())) {
    // ...
}
like image 183
Chris Jester-Young Avatar answered Sep 28 '22 23:09

Chris Jester-Young