void print(){
System.out.println("foo");
}
}
ClassDemo2.java
public class ClassDemo2 {
public static void main(String[] args) {
Class c1 = int.class;//int 的类类型
Class c2 = String.class;//String类的类类型 String类字节码(自己发明的)
Class c3 = double.class;
Class c4 = Double.class;
Class c5 = void.class;
System.out.println(c1.getName());
System.out.println(c2.getName());
System.out.println(c2.getSimpleName());//不包含包名的类的名称
System.out.println(c5.getName());
}
}
ClassDemo3.java
public class ClassDemo3 {
public static void main(String[] args) {
String s = "hello";
ClassUtil.printClassMethodMessage(s);
Integer n1 = 1;
ClassUtil.printClassMethodMessage(n1);
}
}
ClassDemo4.java
public class ClassDemo4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ClassUtil.printFieldMessage("hello");
System.out.println("=============");
ClassUtil.printFieldMessage(new Integer(1));
}
}
ClassDemo5.java
public class ClassDemo5 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
ClassUtil.printConMessage("hello");
ClassUtil.printConMessage(new Integer(1));
}
}