Saturday, September 27, 2014
Generics
public class Genericfactory {
static <T> void printClassnName(T anyType) {
System.out.println(anyType.getClass().getPackage());
System.out.println(anyType.getClass().getName());
}
static void printClassnNameTest(Object test) {
System.out.println(test.getClass().getPackage());
System.out.println(test.getClass().getName());
}
public static void main(String[] args) {
Genericfactory.printClassnName(String.class);
Genericfactory.printClassnName(new String(""));
Genericfactory.printClassnName(Integer.class);
Genericfactory.printClassnName(new Integer(3));
Genericfactory.printClassnName(Genericfactory.class);
Class test= Genericfactory.class;
Genericfactory.printClassnNameTest(test);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment