img
try {
A a = new A();
Class c = a.getClass();
System.out.println("Public Methods:");
Method methods[] = c.getDeclaredMethods();
for(int i = 0; i < methods.length; i++) {
int modifiers = methods[i].getModifiers();
if(Modifier.isPublic(modifiers)) {
System.out.println(" " + methods[i].getName());
}
}
}
catch(Exception e) {
System.out.println("Exception: " + e);
}
}
}
class A {
public void a1() {
}
public void a2() {
}
protected void a3() {
}
private void a4() {
}
}
Here is the output from this program:
Public Methods:
a1
a2
Method
Description
static boolean isAbstract(int val)
Returns true if val has the abstract flag set and false other wise.
static boolean isFinal(int val)
Returns true if val has the final flag set and false other wise.
static boolean isInter face(int val)
Returns true if val has the interface flag set and false other wise.
static boolean isNative(int val)
Returns true if val has the native flag set and false other wise.
static boolean isPrivate(int val)
Returns true if val has the private flag set and false other wise.
static boolean isProtected(int val)
Returns true if val has the protected flag set and false other wise.
static boolean isPublic(int val)
Returns true if val has the public flag set and false other wise.
static boolean isStatic(int val)
Returns true if val has the static flag set and false other wise.
static boolean isStrict(int val)
Returns true if val has the strict flag set and false other wise.
static boolean isSynchronized(int val)
Returns true if val has the synchronized flag set and false other wise.
static boolean isTransient(int val)
Returns true if val has the transient flag set and false other wise.
static boolean isVolatile(int val)
Returns true if val has the volatile flag set and false other wise.
TABLE 27-5
Methods Defined by Modifier That Determine Modifiers
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home