Methods Summary |
---|
public static void | main(java.lang.String[] args)Demonstration Method
final Set classes = new HashSet();
classes.add(Class.class);
classes.add(Comparable.class);
classes.add(Serializable.class);
classes.add(Integer.class);
classes.add(int.class);
classes.add(Float[].class);
classes.add(String.class);
classes.add(double[].class);
classes.add(boolean.class);
// --
System.out.println("Finding interface Class objects in the set.");
Iterator iter = classes.iterator();
while (iter.hasNext()) {
useIsInterface((Class)iter.next());
}
System.out.println("\nFinding primitive Class objects in the set.");
iter = classes.iterator();
while (iter.hasNext()) {
useIsPrimitive((Class)iter.next());
}
System.out.println("\nFinding array Class objects in the set.");
iter = classes.iterator();
while (iter.hasNext()) {
useIsArray((Class)iter.next());
}
|
public static void | useIsArray(java.lang.Class dataType)Demonstrates usage of isArray from Class.
if (dataType == null) {
throw new NullPointerException();
}
if (dataType.isArray()) {
System.out.print(dataType.getName());
System.out.println("\t ==> " + dataType.getComponentType());
}
|
public static void | useIsInterface(java.lang.Class dataType)Demonstrates usage of isInterface from Class.
if (dataType == null) {
throw new NullPointerException();
}
if (dataType.isInterface()) {
System.out.println(dataType.getName());
}
|
public static void | useIsPrimitive(java.lang.Class dataType)Demonstrates usage of isPrimitive from Class.
if (dataType == null) {
throw new NullPointerException();
}
if (dataType.isPrimitive()) {
System.out.println(dataType.getName());
}
|