jdk1.8,ArrayList<String> 不能用了
parameterized types are only available if source level is 1.5
parameterized types are only available if source level is 1.5
2015-04-08
厉害,之前学python的时候,觉得python的dir()好牛逼,原来java的也有。。。 涨姿势了,谢谢老师
2015-04-08
package com.fcy.reflect;
public class Demo2 {
public static void main(String[] args) {
Office o = new Office();
Word w = new Word();
System.out.println(w.getClass().getName());//获取类名
o.load(w.getClass().getName());
Excel e = new Excel();
o.load(e.getClass().getName());
}
}
public class Demo2 {
public static void main(String[] args) {
Office o = new Office();
Word w = new Word();
System.out.println(w.getClass().getName());//获取类名
o.load(w.getClass().getName());
Excel e = new Excel();
o.load(e.getClass().getName());
}
}
2015-04-05
修改了一下,新建了一个类
package com.fcy.reflect;
public class Office {
public void load(String cl){
try {
//动态加载类,在运行时加载
Class c = Class.forName(cl);
//通过类类型,创建该类的对象
OfficeAble oa = (OfficeAble)c.newInstance();
oa.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.fcy.reflect;
public class Office {
public void load(String cl){
try {
//动态加载类,在运行时加载
Class c = Class.forName(cl);
//通过类类型,创建该类的对象
OfficeAble oa = (OfficeAble)c.newInstance();
oa.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
2015-04-05