Java Modifier FINAL
Syntax
Modifier.FINAL has the following syntax.
public static final int FINAL
Example
In the following code shows how to use Modifier.FINAL field.
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
/*from w w w. java 2s.com*/
public class Main {
public static void main(String... args) throws Exception {
Class<?> c = Class.forName("java.lang.String");
Constructor[] allConstructors = c.getDeclaredConstructors();
for (Constructor ctor : allConstructors) {
int searchMod = Modifier.FINAL;
int mods = accessModifiers(ctor.getModifiers());
if (searchMod == mods) {
System.out.println(ctor);
}
}
}
private static int accessModifiers(int m) {
return m & Modifier.FINAL;
}
}