摘要: 泛型的出现使数据类型的错误止步在源码级别上,也就是我们所说的编译型错误。今天就跟大家探讨下Java泛型以及自定义泛型的使用:一、Java中的泛型 1 @Test 2 3 public void test()throws Exception{ 4 5 //把List集合的类型限制在String类类型范围内,在这里使用了泛型 6 7 List<String> list = new ArrayList<String>(); 8 9 //向该集合中插入符合该泛型的数据10 11 list.add("a");12 13 list.add("b&quo 阅读全文
posted @ 2011-03-01 08:04 Laughing_Vzr@Stand By 阅读(605) 评论(0) 推荐(0) 编辑
摘要: BeanUtils工具包是由Apache公司所开发,主要是方便程序员对Bean类能够进行简便的操作。在使用BeanUtils工具包之前我们需要的Jar包有以下几种:(1)BeanUtils相关包commons-beanutils-1.8.3.jarcommons-beanutils-1.8.3-javadoc.jarcommons-beanutils-1.8.3-javadoc.jarcommons-beanutils-bean-collections-1.8.3.jarcommons-beanutils-core-1.8.3.jar(2)Logic4j相关包commons-logging.j 阅读全文
posted @ 2011-03-01 08:01 Laughing_Vzr@Stand By 阅读(34382) 评论(0) 推荐(5) 编辑
摘要: 利用Java中的反射我们可以解析类中各个组成部分,下面将介绍利用反射来解析方法体:首先,我们来先看下所解析类的源码:Student类: 1 public class Student { 2 3 4 5 public static void study(){ 6 7 System.out.println("好好学习、天天向上!"); 8 9 }10 11 public int getSum(int a,int b){12 13 int sum=a+b;14 15 return sum;16 17 }18 19 private void disPlay(String name, 阅读全文
posted @ 2011-02-28 17:16 Laughing_Vzr@Stand By 阅读(691) 评论(0) 推荐(1) 编辑
摘要: 反射不单可以对类中的方法进行解析,还可以对类的字段进行解析;以下为我们要解析的Student类的源码:Student类: 1 public class Student { 2 3 4 5 public static void study(){ 6 7 System.out.println("好好学习、天天向上!"); 8 9 }10 11 public int getSum(int a,int b){12 13 int sum=a+b;14 15 return sum;16 17 }18 19 private void disPlay(String name,int age 阅读全文
posted @ 2011-02-28 17:13 Laughing_Vzr@Stand By 阅读(479) 评论(0) 推荐(0) 编辑
摘要: 为了让程序员们更好的操作Java对象的属性,SUN公司开发了一套API,被业界内称为:内省;内省的出现有利于了对类对象属性的操作,减少了代码的数量。内省访问JavaBean有两种方法:一、通过Introspector类获得Bean对象的BeanInfo,然后通过BeanInfo来获取属性的描述器(PropertyDescriptor),通过这个属性描述器就可以获取某个属性对应的getter/setter方法,然后通过反射机制来调用这些方法。二、通过PropertyDescriptor来操作Bean对象接下来要对Student类对象进行操作,Student类源码如下: 1 public clas 阅读全文
posted @ 2011-02-28 17:11 Laughing_Vzr@Stand By 阅读(7585) 评论(0) 推荐(2) 编辑
摘要: 新来到博客园、以后有问题会多多请教大家的、 阅读全文
posted @ 2010-10-20 09:05 Laughing_Vzr@Stand By 阅读(131) 评论(0) 推荐(0) 编辑