标签:
enum
package cn.jiemoxiaodi_enum; public class School { public static School s1=new School("北1京", "1sdfds"); public static School s2=new School("北京2", "2sdfds"); public static School s3=new School("北京3", "3sdfds"); private String name; private String teacher; @Override public String toString() { return "School [name=" + name + ", teacher=" + teacher + "]"; } private School() { super(); } private School(String name, String teacher) { super(); this.name = name; this.teacher = teacher; } }
---
package cn.jiemoxiaodi_enum; public enum School2 { shanghai("比较", "sdf"), bj("3", "44"), sz("55", "dfd"), hz("sdf", "sdf"); private School2(String name, String ordinal) { } }
int short enum
枚举中可以 用在switch 枚举中必须的进行相关的(abstract Method)实现
反射
万物都是对象:
java=>编译器=》class ==类加载器=》jvm—>
反射就是用来描述与字节码(class)相关的事物
package cn.jiemoxiaodi.reflect; import java.io.FileInputStream; import java.util.Properties; import org.junit.Test; public class UserDaoTest { /** * @param args * @throws Exception * */ @Test public void testUserDao() throws Exception { Properties pro=new Properties(); pro.load(new FileInputStream("src/cn/jiemoxiaodi/reflect/beanname.properties")); String str=pro.get("UserDao").toString(); Class c1 = Class.forName(str); UserDao ud=(UserDao) c1.newInstance(); ud.save(); } }
构造函数 constructor
方法 method
字段 fields
标签:
原文地址:http://www.cnblogs.com/jiemoxiaodi/p/5090424.html