日期:2014-05-20 浏览次数:20790 次
将下列类打入jar包: package com.kouyi.test.vo; public class UserExtend { private String user_id = "1"; private String remark; public String getUser_id() { return user_id; } public void setUser_id(String user_id) { this.user_id = user_id; } public String getRemark() { return remark; } public void setRemark(String remark) { this.remark = remark; } } 新建一个UserExtend类 package com.kouyi.test.action; public class UserExtend { /** * @param args */ public static void main(String[] args) { try { Class cl = ClassLoader.getSystemClassLoader().loadClass("com.kouyi.test.vo.UserExtend"); com.kouyi.test.vo.UserExtend obj = (com.kouyi.test.vo.UserExtend) cl.newInstance(); String ret = obj.getUser_id(); System.out.println(ret); // 输出为1 } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }