Getting the Pair class modifiers

In order to get the modifiers (public, protected, private, final, static, abstract, and interface) of a class, we can call the Class.getModifiers() method. This method returns an int value representing each modifier as a flag bit. For decoding the result, we rely on the Modifier class, as follows:

int modifiers = clazz.getModifiers();

System.out.println("Is public? "
+ Modifier.isPublic(modifiers)); // true
System.out.println("Is final? "
+ Modifier.isFinal(modifiers)); // true
System.out.println("Is abstract? "
+ Modifier.isAbstract(modifiers)); // false
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.38.92