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
厲害,之前學(xué)python的時(shí)候,覺得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
修改了一下,新建了一個(gè)類
package com.fcy.reflect;
public class Office {
public void load(String cl){
try {
//動(dòng)態(tài)加載類,在運(yùn)行時(shí)加載
Class c = Class.forName(cl);
//通過類類型,創(chuàng)建該類的對(duì)象
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 {
//動(dòng)態(tài)加載類,在運(yùn)行時(shí)加載
Class c = Class.forName(cl);
//通過類類型,創(chuàng)建該類的對(duì)象
OfficeAble oa = (OfficeAble)c.newInstance();
oa.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
2015-04-05