Java泛型

Java总结篇系列:Java泛型

一. 泛型概念的提出(为什么需要泛型)?

首先,我们看下下面这段简短的代码:

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4         List list = new ArrayList();
 5         list.add("qqyumidi");
 6         list.add("corn");
 7         list.add(100);
 8 
 9         for (int i = 0; i < list.size(); i++) {
10             String name = (String) list.get(i); // 1
11             System.out.println("name:" + name);
12         }
13     }
14 }
复制代码

定义了一个List类型的集合,先向其中加入了两个字符串类型的值,随后加入一个Integer类型的值。这是完全允许的,因为此时list默认的类型为Object类型。在之后的循环中,由于忘记了之前在list中也加入了Integer类型的值或其他编码原因,很容易出现类似于//1中的错误。因为编译阶段正常,而运行时会出现“java.lang.ClassCastException”异常。因此,导致此类错误编码过程中不易发现。

 在如上的编码过程中,我们发现主要存在两个问题:

1.当我们将一个对象放入集合中,集合不会记住此对象的类型,当再次从集合中取出此对象时,改对象的编译类型变成了Object类型,但其运行时类型任然为其本身类型。

2.因此,//1处取出集合元素时需要人为的强制类型转化到具体的目标类型,且很容易出现“java.lang.ClassCastException”异常。

那么有没有什么办法可以使集合能够记住集合内元素各类型,且能够达到只要编译时不出现问题,运行时就不会出现“java.lang.ClassCastException”异常呢?答案就是使用泛型。

 

二.什么是泛型?

泛型,即“参数化类型”。一提到参数,最熟悉的就是定义方法时有形参,然后调用此方法时传递实参。那么参数化类型怎么理解呢?顾名思义,就是将类型由原来的具体的类型参数化,类似于方法中的变量参数,此时类型也定义成参数形式(可以称之为类型形参),然后在使用/调用时传入具体的类型(类型实参)。

 看着好像有点复杂,首先我们看下上面那个例子采用泛型的写法。

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4         /*
 5         List list = new ArrayList();
 6         list.add("qqyumidi");
 7         list.add("corn");
 8         list.add(100);
 9         */
10 
11         List<String> list = new ArrayList<String>();
12         list.add("qqyumidi");
13         list.add("corn");
14         //list.add(100);   // 1  提示编译错误
15 
16         for (int i = 0; i < list.size(); i++) {
17             String name = list.get(i); // 2
18             System.out.println("name:" + name);
19         }
20     }
21 }
复制代码

采用泛型写法后,在//1处想加入一个Integer类型的对象时会出现编译错误,通过List<String>,直接限定了list集合中只能含有String类型的元素,从而在//2处无须进行强制类型转换,因为此时,集合能够记住元素的类型信息,编译器已经能够确认它是String类型了。

结合上面的泛型定义,我们知道在List<String>中,String是类型实参,也就是说,相应的List接口中肯定含有类型形参。且get()方法的返回结果也直接是此形参类型(也就是对应的传入的类型实参)。下面就来看看List接口的的具体定义:

复制代码
 1 public interface List<E> extends Collection<E> {
 2 
 3     int size();
 4 
 5     boolean isEmpty();
 6 
 7     boolean contains(Object o);
 8 
 9     Iterator<E> iterator();
10 
11     Object[] toArray();
12 
13     <T> T[] toArray(T[] a);
14 
15     boolean add(E e);
16 
17     boolean remove(Object o);
18 
19     boolean containsAll(Collection<?> c);
20 
21     boolean addAll(Collection<? extends E> c);
22 
23     boolean addAll(int index, Collection<? extends E> c);
24 
25     boolean removeAll(Collection<?> c);
26 
27     boolean retainAll(Collection<?> c);
28 
29     void clear();
30 
31     boolean equals(Object o);
32 
33     int hashCode();
34 
35     E get(int index);
36 
37     E set(int index, E element);
38 
39     void add(int index, E element);
40 
41     E remove(int index);
42 
43     int indexOf(Object o);
44 
45     int lastIndexOf(Object o);
46 
47     ListIterator<E> listIterator();
48 
49     ListIterator<E> listIterator(int index);
50 
51     List<E> subList(int fromIndex, int toIndex);
52 }
复制代码

我们可以看到,在List接口中采用泛型化定义之后,<E>中的E表示类型形参,可以接收具体的类型实参,并且此接口定义中,凡是出现E的地方均表示相同的接受自外部的类型实参。

自然的,ArrayList作为List接口的实现类,其定义形式是:

复制代码
 1 public class ArrayList<E> extends AbstractList<E> 
 2         implements List<E>, RandomAccess, Cloneable, java.io.Serializable {
 3     
 4     public boolean add(E e) {
 5         ensureCapacityInternal(size + 1);  // Increments modCount!!
 6         elementData[size++] = e;
 7         return true;
 8     }
 9     
10     public E get(int index) {
11         rangeCheck(index);
12         checkForComodification();
13         return ArrayList.this.elementData(offset + index);
14     }
15     
16     //...省略掉其他具体的定义过程
17 
18 }
复制代码

由此,我们从源代码角度明白了为什么//1处加入Integer类型对象编译错误,且//2处get()到的类型直接就是String类型了。

 

三.自定义泛型接口、泛型类和泛型方法

从上面的内容中,大家已经明白了泛型的具体运作过程。也知道了接口、类和方法也都可以使用泛型去定义,以及相应的使用。是的,在具体使用时,可以分为泛型接口、泛型类和泛型方法。

自定义泛型接口、泛型类和泛型方法与上述Java源码中的List、ArrayList类似。如下,我们看一个最简单的泛型类和方法定义:

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<String> name = new Box<String>("corn");
 6         System.out.println("name:" + name.getData());
 7     }
 8 
 9 }
10 
11 class Box<T> {
12 
13     private T data;
14 
15     public Box() {
16 
17     }
18 
19     public Box(T data) {
20         this.data = data;
21     }
22 
23     public T getData() {
24         return data;
25     }
26 
27 } 
复制代码

在泛型接口、泛型类和泛型方法的定义过程中,我们常见的如T、E、K、V等形式的参数常用于表示泛型形参,由于接收来自外部使用时候传入的类型实参。那么对于不同传入的类型实参,生成的相应对象实例的类型是不是一样的呢?

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<String> name = new Box<String>("corn");
 6         Box<Integer> age = new Box<Integer>(712);
 7 
 8         System.out.println("name class:" + name.getClass());      // com.qqyumidi.Box
 9         System.out.println("age class:" + age.getClass());        // com.qqyumidi.Box
10         System.out.println(name.getClass() == age.getClass());    // true
11 
12     }
13 
14 }
复制代码

由此,我们发现,在使用泛型类时,虽然传入了不同的泛型实参,但并没有真正意义上生成不同的类型,传入不同泛型实参的泛型类在内存上只有一个,即还是原来的最基本的类型(本实例中为Box),当然,在逻辑上我们可以理解成多个不同的泛型类型。

究其原因,在于Java中的泛型这一概念提出的目的,导致其只是作用于代码编译阶段,在编译过程中,对于正确检验泛型结果后,会将泛型的相关信息擦出,也就是说,成功编译过后的class文件中是不包含任何泛型信息的。泛型信息不会进入到运行时阶段。

对此总结成一句话:泛型类型在逻辑上看以看成是多个不同的类型,实际上都是相同的基本类型。

 

四.类型通配符

接着上面的结论,我们知道,Box<Number>和Box<Integer>实际上都是Box类型,现在需要继续探讨一个问题,那么在逻辑上,类似于Box<Number>和Box<Integer>是否可以看成具有父子关系的泛型类型呢?

为了弄清这个问题,我们继续看下下面这个例子:

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<Number> name = new Box<Number>(99);
 6         Box<Integer> age = new Box<Integer>(712);
 7 
 8         getData(name);
 9         
10         //The method getData(Box<Number>) in the type GenericTest is 
11         //not applicable for the arguments (Box<Integer>)
12         getData(age);   // 1
13 
14     }
15     
16     public static void getData(Box<Number> data){
17         System.out.println("data :" + data.getData());
18     }
19 
20 }
复制代码

我们发现,在代码//1处出现了错误提示信息:The method getData(Box<Number>) in the t ype GenericTest is not applicable for the arguments (Box<Integer>)。显然,通过提示信息,我们知道Box<Number>在逻辑上不能视为Box<Integer>的父类。那么,原因何在呢?

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<Integer> a = new Box<Integer>(712);
 6         Box<Number> b = a;  // 1
 7         Box<Float> f = new Box<Float>(3.14f);
 8         b.setData(f);        // 2
 9 
10     }
11 
12     public static void getData(Box<Number> data) {
13         System.out.println("data :" + data.getData());
14     }
15 
16 }
17 
18 class Box<T> {
19 
20     private T data;
21 
22     public Box() {
23 
24     }
25 
26     public Box(T data) {
27         setData(data);
28     }
29 
30     public T getData() {
31         return data;
32     }
33 
34     public void setData(T data) {
35         this.data = data;
36     }
37 
38 }
复制代码

这个例子中,显然//1和//2处肯定会出现错误提示的。在此我们可以使用反证法来进行说明。

假设Box<Number>在逻辑上可以视为Box<Integer>的父类,那么//1和//2处将不会有错误提示了,那么问题就出来了,通过getData()方法取出数据时到底是什么类型呢?Integer? Float? 还是Number?且由于在编程过程中的顺序不可控性,导致在必要的时候必须要进行类型判断,且进行强制类型转换。显然,这与泛型的理念矛盾,因此,在逻辑上Box<Number>不能视为Box<Integer>的父类。

好,那我们回过头来继续看“类型通配符”中的第一个例子,我们知道其具体的错误提示的深层次原因了。那么如何解决呢?总部能再定义一个新的函数吧。这和Java中的多态理念显然是违背的,因此,我们需要一个在逻辑上可以用来表示同时是Box<Integer>和Box<Number>的父类的一个引用类型,由此,类型通配符应运而生。

类型通配符一般是使用 ? 代替具体的类型实参。注意了,此处是类型实参,而不是类型形参!且Box<?>在逻辑上是Box<Integer>、Box<Number>...等所有Box<具体类型实参>的父类。由此,我们依然可以定义泛型方法,来完成此类需求。

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<String> name = new Box<String>("corn");
 6         Box<Integer> age = new Box<Integer>(712);
 7         Box<Number> number = new Box<Number>(314);
 8 
 9         getData(name);
10         getData(age);
11         getData(number);
12     }
13 
14     public static void getData(Box<?> data) {
15         System.out.println("data :" + data.getData());
16     }
17 
18 }
复制代码

有时候,我们还可能听到类型通配符上限和类型通配符下限。具体有是怎么样的呢?

在上面的例子中,如果需要定义一个功能类似于getData()的方法,但对类型实参又有进一步的限制:只能是Number类及其子类。此时,需要用到类型通配符上限。

复制代码
 1 public class GenericTest {
 2 
 3     public static void main(String[] args) {
 4 
 5         Box<String> name = new Box<String>("corn");
 6         Box<Integer> age = new Box<Integer>(712);
 7         Box<Number> number = new Box<Number>(314);
 8 
 9         getData(name);
10         getData(age);
11         getData(number);
12         
13         //getUpperNumberData(name); // 1
14         getUpperNumberData(age);    // 2
15         getUpperNumberData(number); // 3
16     }
17 
18     public static void getData(Box<?> data) {
19         System.out.println("data :" + data.getData());
20     }
21     
22     public static void getUpperNumberData(Box<? extends Number> data){
23         System.out.println("data :" + data.getData());
24     }
25 
26 }
复制代码

此时,显然,在代码//1处调用将出现错误提示,而//2 //3处调用正常。

类型通配符上限通过形如Box<? extends Number>形式定义,相对应的,类型通配符下限为Box<? super Number>形式,其含义与类型通配符上限正好相反,在此不作过多阐述了。

 

五.话外篇

本文中的例子主要是为了阐述泛型中的一些思想而简单举出的,并不一定有着实际的可用性。另外,一提到泛型,相信大家用到最多的就是在集合中,其实,在实际的编程过程中,自己可以使用泛型去简化开发,且能很好的保证代码质量。并且还要注意的一点是,Java中没有所谓的泛型数组一说。

对于泛型,最主要的还是需要理解其背后的思想和目的。

 

 

 开启微信公众号之旅。

 写下自己经历的,感悟的,和随想的。

 欢迎扫码关注。

 

---------------------------------------------------------------------------------
笔者水平有限,若有错漏,欢迎指正,如果转载以及CV操作,请务必注明出处,谢谢!
分类: Java
181
3
« 上一篇: Java总结篇系列:Java多线程(三)
» 下一篇: Android开发中的问题及相应解决(持续更新)
	</div>
	<div class="postDesc">posted @ <span id="post-date">2014-07-12 23:39</span> <a href="https://www.cnblogs.com/lwbqqyumidi/">Windstep</a> 阅读(<span id="post_view_count">538176</span>) 评论(<span id="post_comment_count">99</span>)  <a href="https://i.cnblogs.com/EditPosts.aspx?postid=3837629" rel="nofollow">编辑</a> <a href="#" onclick="AddToWz(3837629);return false;">收藏</a></div>
</div>
<script type="text/javascript">var allowComments=true,cb_blogId=122301,cb_entryId=3837629,cb_blogApp=currentBlogApp,cb_blogUserGuid='e6cf342b-cfcb-e111-aa3f-842b2b196315',cb_entryCreatedDate='2014/7/12 23:39:00';loadViewCount(cb_entryId);var cb_postType=1;</script>
< Prev 1 2

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3495497" class="layer">#51楼</a><a name="3495497" id="comment_anchor_3495497"></a>  <span class="comment_date">2016-08-24 14:39</span> <a id="a_comment_author_3495497" href="https://www.cnblogs.com/zzry/" target="_blank">一百零七个</a> <a href="http://msg.cnblogs.com/send/%E4%B8%80%E7%99%BE%E9%9B%B6%E4%B8%83%E4%B8%AA" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3495497" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3495497,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3495497,'Bury',this)">反对(0)</a></div><span id="comment_3495497_avatar" style="display:none;">http://pic.cnblogs.com/face/983981/20160629093639.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3505446" class="layer">#52楼</a><a name="3505446" id="comment_anchor_3505446"></a>  <span class="comment_date">2016-09-07 17:35</span> <a id="a_comment_author_3505446" href="https://www.cnblogs.com/lijiale/" target="_blank">java渣渣</a> <a href="http://msg.cnblogs.com/send/java%E6%B8%A3%E6%B8%A3" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3505446" class="blog_comment_body">简单的说 泛型就是函数的参数类型可以变化</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3505446,'Digg',this)">支持(8)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3505446,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3508389" class="layer">#53楼</a><a name="3508389" id="comment_anchor_3508389"></a>  <span class="comment_date">2016-09-12 10:02</span> <a id="a_comment_author_3508389" href="http://home.cnblogs.com/u/1025111/" target="_blank">浅冰</a> <a href="http://msg.cnblogs.com/send/%E6%B5%85%E5%86%B0" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3508389" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3508389,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3508389,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3509709" class="layer">#54楼</a><a name="3509709" id="comment_anchor_3509709"></a>  <span class="comment_date">2016-09-13 14:51</span> <a id="a_comment_author_3509709" href="https://www.cnblogs.com/mxlIT/" target="_blank">一路登峰</a> <a href="http://msg.cnblogs.com/send/%E4%B8%80%E8%B7%AF%E7%99%BB%E5%B3%B0" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3509709" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3509709,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3509709,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3520177" class="layer">#55楼</a><a name="3520177" id="comment_anchor_3520177"></a>  <span class="comment_date">2016-09-27 09:36</span> <a id="a_comment_author_3520177" href="https://www.cnblogs.com/freedommovie/" target="_blank">杉枫</a> <a href="http://msg.cnblogs.com/send/%E6%9D%89%E6%9E%AB" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3520177" class="blog_comment_body">泛型需要深入的分析理解</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3520177,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3520177,'Bury',this)">反对(0)</a></div><span id="comment_3520177_avatar" style="display:none;">http://pic.cnblogs.com/face/942404/20160810174243.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3524751" class="layer">#56楼</a><a name="3524751" id="comment_anchor_3524751"></a>  <span class="comment_date">2016-10-06 12:46</span> <a id="a_comment_author_3524751" href="http://home.cnblogs.com/u/999512/" target="_blank">幻世无双520</a> <a href="http://msg.cnblogs.com/send/%E5%B9%BB%E4%B8%96%E6%97%A0%E5%8F%8C520" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3524751" class="blog_comment_body">似懂非懂  看不懂,不明嚼栗-2016-10-06 12:46<br>没想到16年就已经看过了 如今来看 能勉强看懂了-2018年2月23日11:38</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3524751,'Digg',this)">支持(7)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3524751,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3526491" class="layer">#57楼</a><a name="3526491" id="comment_anchor_3526491"></a>  <span class="comment_date">2016-10-09 15:58</span> <a id="a_comment_author_3526491" href="http://home.cnblogs.com/u/1036654/" target="_blank">LiuJinChong</a> <a href="http://msg.cnblogs.com/send/LiuJinChong" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3526491" class="blog_comment_body">看得懂</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3526491,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3526491,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3578705" class="layer">#58楼</a><a name="3578705" id="comment_anchor_3578705"></a>  <span class="comment_date">2016-12-12 16:48</span> <a id="a_comment_author_3578705" href="https://www.cnblogs.com/lyh421/" target="_blank">七月流火嗞嗞嗞</a> <a href="http://msg.cnblogs.com/send/%E4%B8%83%E6%9C%88%E6%B5%81%E7%81%AB%E5%97%9E%E5%97%9E%E5%97%9E" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3578705" class="blog_comment_body">写的很好,逻辑清晰,通俗易懂,而且还不是光讲结论和概念。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3578705,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3578705,'Bury',this)">反对(0)</a></div><span id="comment_3578705_avatar" style="display:none;">http://pic.cnblogs.com/face/980658/20160823152625.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3580706" class="layer">#59楼</a><a name="3580706" id="comment_anchor_3580706"></a>  <span class="comment_date">2016-12-14 16:55</span> <a id="a_comment_author_3580706" href="https://www.cnblogs.com/lulipro/" target="_blank">lulipro</a> <a href="http://msg.cnblogs.com/send/lulipro" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3580706" class="blog_comment_body">不够深入</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3580706,'Digg',this)">支持(2)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3580706,'Bury',this)">反对(0)</a></div><span id="comment_3580706_avatar" style="display:none;">http://pic.cnblogs.com/face/858860/20170316220126.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3587615" class="layer">#60楼</a><a name="3587615" id="comment_anchor_3587615"></a>  <span class="comment_date">2016-12-23 09:01</span> <a id="a_comment_author_3587615" href="https://www.cnblogs.com/Lumia1020/" target="_blank">Lumia1020</a> <a href="http://msg.cnblogs.com/send/Lumia1020" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3587615" class="blog_comment_body">写的很好</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3587615,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3587615,'Bury',this)">反对(0)</a></div><span id="comment_3587615_avatar" style="display:none;">http://pic.cnblogs.com/face/620936/20170119143545.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3590571" class="layer">#61楼</a><a name="3590571" id="comment_anchor_3590571"></a>  <span class="comment_date">2016-12-27 14:59</span> <a id="a_comment_author_3590571" href="https://www.cnblogs.com/aiweixiao/" target="_blank">程序员的文娱情怀</a> <a href="http://msg.cnblogs.com/send/%E7%A8%8B%E5%BA%8F%E5%91%98%E7%9A%84%E6%96%87%E5%A8%B1%E6%83%85%E6%80%80" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3590571" class="blog_comment_body"><a href="#3495497" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3495497);">@</a>

一百零七个
mark, java 泛型~

http://pic.cnblogs.com/face/676456/20161122190156.png

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3613059" class="layer">#62楼</a><a name="3613059" id="comment_anchor_3613059"></a>  <span class="comment_date">2017-02-06 23:02</span> <a id="a_comment_author_3613059" href="https://www.cnblogs.com/cyfonly/" target="_blank">cyfonly</a> <a href="http://msg.cnblogs.com/send/cyfonly" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3613059" class="blog_comment_body">足够浅出,思路清晰,易懂。希望作者再来一篇深入的。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3613059,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3613059,'Bury',this)">反对(0)</a></div><span id="comment_3613059_avatar" style="display:none;">http://pic.cnblogs.com/face/897247/20160522165816.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3613517" class="layer">#63楼</a><a name="3613517" id="comment_anchor_3613517"></a>  <span class="comment_date">2017-02-07 15:31</span> <a id="a_comment_author_3613517" href="https://www.cnblogs.com/roy-blog/" target="_blank">xdxxdx</a> <a href="http://msg.cnblogs.com/send/xdxxdx" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3613517" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3613517,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3613517,'Bury',this)">反对(0)</a></div><span id="comment_3613517_avatar" style="display:none;">http://pic.cnblogs.com/face/998564/20171214120012.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3626459" class="layer">#64楼</a><a name="3626459" id="comment_anchor_3626459"></a>  <span class="comment_date">2017-02-25 18:13</span> <a id="a_comment_author_3626459" href="http://home.cnblogs.com/u/1043228/" target="_blank">望雪</a> <a href="http://msg.cnblogs.com/send/%E6%9C%9B%E9%9B%AA" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3626459" class="blog_comment_body">这么抽象的东西,看了一遍竟然没看懂。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3626459,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3626459,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3626677" class="layer">#65楼</a><a name="3626677" id="comment_anchor_3626677"></a>  <span class="comment_date">2017-02-26 10:34</span> <a id="a_comment_author_3626677" href="http://home.cnblogs.com/u/1113645/" target="_blank">yansensensen</a> <a href="http://msg.cnblogs.com/send/yansensensen" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3626677" class="blog_comment_body">看了一遍就看懂了,通俗易懂,厉害</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3626677,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3626677,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3634106" class="layer">#66楼</a><a name="3634106" id="comment_anchor_3634106"></a>  <span class="comment_date">2017-03-07 17:28</span> <a id="a_comment_author_3634106" href="https://www.cnblogs.com/zepx/" target="_blank">Zepx</a> <a href="http://msg.cnblogs.com/send/Zepx" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3634106" class="blog_comment_body">看完之后陷入江局了</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3634106,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3634106,'Bury',this)">反对(0)</a></div><span id="comment_3634106_avatar" style="display:none;">http://pic.cnblogs.com/face/1119074/20170421092742.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3637112" class="layer">#67楼</a><a name="3637112" id="comment_anchor_3637112"></a>  <span class="comment_date">2017-03-10 15:47</span> <a id="a_comment_author_3637112" href="https://www.cnblogs.com/wscrlhs/" target="_blank">昼伏夜奔</a> <a href="http://msg.cnblogs.com/send/%E6%98%BC%E4%BC%8F%E5%A4%9C%E5%A5%94" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3637112" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3637112,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3637112,'Bury',this)">反对(0)</a></div><span id="comment_3637112_avatar" style="display:none;">http://pic.cnblogs.com/face/887281/20160126172254.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3649334" class="layer">#68楼</a><a name="3649334" id="comment_anchor_3649334"></a>  <span class="comment_date">2017-03-23 11:40</span> <a id="a_comment_author_3649334" href="https://www.cnblogs.com/donghang/" target="_blank">donghang4</a> <a href="http://msg.cnblogs.com/send/donghang4" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3649334" class="blog_comment_body"><a href="#3640695" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3640695);">@</a>

我来也1010
转发什么意思啊,初级玩家表示不理解你的说法



	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3654742" class="layer">#69楼</a><a name="3654742" id="comment_anchor_3654742"></a>  <span class="comment_date">2017-03-29 15:47</span> <a id="a_comment_author_3654742" href="https://www.cnblogs.com/qingyan123/" target="_blank">颜如玉Token</a> <a href="http://msg.cnblogs.com/send/%E9%A2%9C%E5%A6%82%E7%8E%89Token" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3654742" class="blog_comment_body">专门找回密码登录就为点个赞 鼓励鼓励!<br>良心好文 谢谢!</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3654742,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3654742,'Bury',this)">反对(0)</a></div><span id="comment_3654742_avatar" style="display:none;">http://pic.cnblogs.com/face/621060/20161020103600.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3672177" class="layer">#70楼</a><a name="3672177" id="comment_anchor_3672177"></a>  <span class="comment_date">2017-04-19 22:53</span> <a id="a_comment_author_3672177" href="http://home.cnblogs.com/u/1085322/" target="_blank">我就是东东1</a> <a href="http://msg.cnblogs.com/send/%E6%88%91%E5%B0%B1%E6%98%AF%E4%B8%9C%E4%B8%9C1" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3672177" class="blog_comment_body">感谢楼主</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3672177,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3672177,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3679229" class="layer">#71楼</a><a name="3679229" id="comment_anchor_3679229"></a>  <span class="comment_date">2017-04-28 10:55</span> <a id="a_comment_author_3679229" href="http://home.cnblogs.com/u/844632/" target="_blank">heroinqiao</a> <a href="http://msg.cnblogs.com/send/heroinqiao" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3679229" class="blog_comment_body">public static &lt;T&gt; T getBean(Class&lt;T&gt; requiredType) {<br>		assertContextInjected();<br>		return applicationContext.getBean(requiredType);<br>	}<br><br>问一下这个方法的返回值为什么是&lt;T&gt; T</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3679229,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3679229,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3685876" class="layer">#72楼</a><a name="3685876" id="comment_anchor_3685876"></a>  <span class="comment_date">2017-05-07 16:26</span> <a id="a_comment_author_3685876" href="https://www.cnblogs.com/yidaijiankuanzhongbuhui/" target="_blank">衣带渐宽终不悔</a> <a href="http://msg.cnblogs.com/send/%E8%A1%A3%E5%B8%A6%E6%B8%90%E5%AE%BD%E7%BB%88%E4%B8%8D%E6%82%94" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3685876" class="blog_comment_body">由浅到深,很佩服作者。<br>但是这段代码是否有误:<br>5          Box&lt;Integer&gt; a = new Box&lt;Integer&gt;(712);<br> 6         Box&lt;Number&gt; b = a;  // 1<br> 7         Box&lt;Float&gt; f = new Box&lt;Float&gt;(3.14f);<br> 8         b.setData(f);        // 2<br><br>虽然setData()方法是使用泛型定义的,但是b.setData(f) 中的f 是一个Box类型的,</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3685876,'Digg',this)">支持(3)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3685876,'Bury',this)">反对(0)</a></div><span id="comment_3685876_avatar" style="display:none;">http://pic.cnblogs.com/face/885267/20160731113734.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3692949" class="layer">#73楼</a><a name="3692949" id="comment_anchor_3692949"></a>  <span class="comment_date">2017-05-16 00:31</span> <a id="a_comment_author_3692949" href="http://home.cnblogs.com/u/531456/" target="_blank">鹏城</a> <a href="http://msg.cnblogs.com/send/%E9%B9%8F%E5%9F%8E" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3692949" class="blog_comment_body">感觉开发过程中用的很少,但是在大神的代码框架中又很常见。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3692949,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3692949,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3722062" class="layer">#74楼</a><a name="3722062" id="comment_anchor_3722062"></a>  <span class="comment_date">2017-06-24 23:28</span> <a id="a_comment_author_3722062" href="https://www.cnblogs.com/zzzz76/" target="_blank">小z同学</a> <a href="http://msg.cnblogs.com/send/%E5%B0%8Fz%E5%90%8C%E5%AD%A6" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3722062" class="blog_comment_body">我要打赏,打赏打赏,写的真好,妈蛋太赞了</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3722062,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3722062,'Bury',this)">反对(0)</a></div><span id="comment_3722062_avatar" style="display:none;">http://pic.cnblogs.com/face/1039974/20170704152414.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3733570" class="layer">#75楼</a><a name="3733570" id="comment_anchor_3733570"></a>  <span class="comment_date">2017-07-12 14:28</span> <a id="a_comment_author_3733570" href="http://home.cnblogs.com/u/663459/" target="_blank">**安静**</a> <a href="http://msg.cnblogs.com/send/%2A%2A%E5%AE%89%E9%9D%99%2A%2A" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3733570" class="blog_comment_body">写的挺好,看完了,例子也运行了一遍,不过上限下限还没弄明白</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3733570,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3733570,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3741468" class="layer">#76楼</a><a name="3741468" id="comment_anchor_3741468"></a>  <span class="comment_date">2017-07-23 13:45</span> <a id="a_comment_author_3741468" href="http://home.cnblogs.com/u/1176724/" target="_blank">阿凡提的小毛驴</a> <a href="http://msg.cnblogs.com/send/%E9%98%BF%E5%87%A1%E6%8F%90%E7%9A%84%E5%B0%8F%E6%AF%9B%E9%A9%B4" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3741468" class="blog_comment_body">不错啦</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3741468,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3741468,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3742123" class="layer">#77楼</a><a name="3742123" id="comment_anchor_3742123"></a>  <span class="comment_date">2017-07-24 14:36</span> <a id="a_comment_author_3742123" href="https://www.cnblogs.com/yjwang11/" target="_blank">蜗牛都甩掉</a> <a href="http://msg.cnblogs.com/send/%E8%9C%97%E7%89%9B%E9%83%BD%E7%94%A9%E6%8E%89" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3742123" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3742123,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3742123,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3745490" class="layer">#78楼</a><a name="3745490" id="comment_anchor_3745490"></a>  <span class="comment_date">2017-07-28 11:49</span> <a id="a_comment_author_3745490" href="https://www.cnblogs.com/xiaolei1004/" target="_blank">小磊Java</a> <a href="http://msg.cnblogs.com/send/%E5%B0%8F%E7%A3%8AJava" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3745490" class="blog_comment_body"><a href="#3489216" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3489216);">@</a>

netwelfare
找不到全部的。。里面有几个链接无法点进去

http://pic.cnblogs.com/face/1003047/20180716175251.png

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3750163" class="layer">#79楼</a><a name="3750163" id="comment_anchor_3750163"></a>  <span class="comment_date">2017-08-03 19:54</span> <a id="a_comment_author_3750163" href="https://www.cnblogs.com/benxi/" target="_blank">倍加珍兮</a> <a href="http://msg.cnblogs.com/send/%E5%80%8D%E5%8A%A0%E7%8F%8D%E5%85%AE" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3750163" class="blog_comment_body">public interface DaoImp&lt;E&gt; {<br>	Collection&lt;E&gt; select();<br>	void delete(String str);<br>	void insert(E u);<br>	void update(E u,String name);<br>}<br>public class UserDao implements DaoImp&lt;User&gt;{<br>	DBConnection db = new MysqlConnection();<br>	@Override<br>	public HashSet&lt;User&gt; select() {<br>		// TODO Auto-generated method stub<br>		Connection conn = db.getConnection();<br>		HashSet&lt;User&gt; list = new HashSet&lt;User&gt;();<br>		try {<br>			String sql = "select * from User";<br>			PreparedStatement ps = conn.prepareStatement(sql);<br>			ResultSet rs = ps.executeQuery();<br>			while(rs.next()){<br>				User u = new User();<br>				u.setName(rs.getString("name"));<br>				u.setPassword(rs.getString("password"));<br>				list.add(u);<br>			}<br>		} catch (SQLException e) {<br>			// TODO Auto-generated catch block<br>			e.printStackTrace();<br>		}finally{<br>			db.closeConnection(conn);<br>		}<br>		return list;<br>	}<br>。。。。。。下面省略<br>class Manger{<br>	private Scanner sc = new Scanner(System.in);<br>	private DaoImp&lt;User&gt; udi = new UserDao();<br>	private DaoImp&lt;Goods&gt; gdi = new GoodsDao();<br>	private DaoImp&lt;phone&gt; pdi = new phoneDao();<br>	public void denglu(){<br>		System.out.println("欢迎登陆系统!");<br>		System.out.println("请输入用户名:");<br>		String userName = sc.next();<br>		System.out.println("请输入密码:");<br>		String password = sc.next();<br>HashSet&lt;User&gt; list = udi.select();<br>		boolean bool = false;<br>		for (User user : list) {<br>			if(user.getName().equals(userName)&amp;&amp;user.getPassword().equals(password)){<br>				bool = true;<br>				System.out.println("登陆成功!");<br>				break;<br>			}<br>		}<br>		if(bool)<br>			emun();<br>		else{<br>			System.out.println("登陆失败!返回");<br>			index();<br>		}<br>	}</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3750163,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3750163,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3753261" class="layer">#80楼</a><a name="3753261" id="comment_anchor_3753261"></a>  <span class="comment_date">2017-08-08 21:12</span> <a id="a_comment_author_3753261" href="https://www.cnblogs.com/s3abiscuit/" target="_blank">s3abiscuit</a> <a href="http://msg.cnblogs.com/send/s3abiscuit" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3753261" class="blog_comment_body">思路很清晰,懂了</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3753261,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3753261,'Bury',this)">反对(0)</a></div><span id="comment_3753261_avatar" style="display:none;">http://pic.cnblogs.com/face/1166062/20170731165151.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3783157" class="layer">#81楼</a><a name="3783157" id="comment_anchor_3783157"></a>  <span class="comment_date">2017-09-13 15:16</span> <a id="a_comment_author_3783157" href="http://home.cnblogs.com/u/1225780/" target="_blank">Captain_rain</a> <a href="http://msg.cnblogs.com/send/Captain_rain" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3783157" class="blog_comment_body"><a href="#3679229" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3679229);">@</a>

heroinqiao
引用
public static <T> T getBean(Class<T> requiredType) {
assertContextInjected();
return applicationContext.getBean(requiredType);
}

问一下这个方法的返回值为什么是<T> T

因为你自己定义的啊,static 后面你自己不是定义了类型吗



	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3798093" class="layer">#82楼</a><a name="3798093" id="comment_anchor_3798093"></a>  <span class="comment_date">2017-09-27 10:43</span> <a id="a_comment_author_3798093" href="https://www.cnblogs.com/cyfonly/" target="_blank">cyfonly</a> <a href="http://msg.cnblogs.com/send/cyfonly" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3798093" class="blog_comment_body">good</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3798093,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3798093,'Bury',this)">反对(0)</a></div><span id="comment_3798093_avatar" style="display:none;">http://pic.cnblogs.com/face/897247/20160522165816.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3800580" class="layer">#83楼</a><a name="3800580" id="comment_anchor_3800580"></a>  <span class="comment_date">2017-09-29 16:09</span> <a id="a_comment_author_3800580" href="http://home.cnblogs.com/u/1233893/" target="_blank">越兮</a> <a href="http://msg.cnblogs.com/send/%E8%B6%8A%E5%85%AE" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3800580" class="blog_comment_body">可以可以,值得一看</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3800580,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3800580,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3808145" class="layer">#84楼</a><a name="3808145" id="comment_anchor_3808145"></a>  <span class="comment_date">2017-10-12 10:55</span> <a id="a_comment_author_3808145" href="http://home.cnblogs.com/u/1178429/" target="_blank">Amanduzhuojiang</a> <a href="http://msg.cnblogs.com/send/Amanduzhuojiang" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3808145" class="blog_comment_body">Nice!</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3808145,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3808145,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3830760" class="layer">#85楼</a><a name="3830760" id="comment_anchor_3830760"></a>  <span class="comment_date">2017-11-04 12:04</span> <a id="a_comment_author_3830760" href="http://home.cnblogs.com/u/1272331/" target="_blank">瞅一眼</a> <a href="http://msg.cnblogs.com/send/%E7%9E%85%E4%B8%80%E7%9C%BC" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3830760" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3830760,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3830760,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3834661" class="layer">#86楼</a><a name="3834661" id="comment_anchor_3834661"></a>  <span class="comment_date">2017-11-08 12:04</span> <a id="a_comment_author_3834661" href="http://home.cnblogs.com/u/1266738/" target="_blank">wwx_man</a> <a href="http://msg.cnblogs.com/send/wwx_man" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3834661" class="blog_comment_body">一般来说,因为所有类都继承object,所以在实现某个,比如说一个能够接受各种类型的参数就设为object,但取值的时候就得转换类型,但现在有了泛型就可以省去转换类型这一步骤,并且达到和用object一样的作用,还不用转换,简便开发。</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3834661,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3834661,'Bury',this)">反对(2)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3846523" class="layer">#87楼</a><a name="3846523" id="comment_anchor_3846523"></a>  <span class="comment_date">2017-11-21 16:09</span> <a id="a_comment_author_3846523" href="https://www.cnblogs.com/publicmain/" target="_blank">publicmain</a> <a href="http://msg.cnblogs.com/send/publicmain" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3846523" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3846523,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(3846523,'Bury',this)">反对(0)</a></div><span id="comment_3846523_avatar" style="display:none;">http://pic.cnblogs.com/face/1172594/20181025104946.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#3922523" class="layer">#88楼</a><a name="3922523" id="comment_anchor_3922523"></a>  <span class="comment_date">2018-03-14 11:39</span> <a id="a_comment_author_3922523" href="http://home.cnblogs.com/u/1024865/" target="_blank">棠棠汤</a> <a href="http://msg.cnblogs.com/send/%E6%A3%A0%E6%A3%A0%E6%B1%A4" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_3922523" class="blog_comment_body"><a href="#3578705" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3578705);">@</a>

七月流火嗞嗞嗞
通俗易懂,赞(≧▽≦)/



	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4001202" class="layer">#89楼</a><a name="4001202" id="comment_anchor_4001202"></a>  <span class="comment_date">2018-06-19 22:59</span> <a id="a_comment_author_4001202" href="https://www.cnblogs.com/baxianhua/" target="_blank">筱筱的春天</a> <a href="http://msg.cnblogs.com/send/%E7%AD%B1%E7%AD%B1%E7%9A%84%E6%98%A5%E5%A4%A9" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4001202" class="blog_comment_body">public class ArrayList&lt;E&gt; extends AbstractList&lt;E&gt; <br>        implements List&lt;E&gt;, RandomAccess, Cloneable, java.io.Serializable {<br>    <br>    public boolean add(E e) {<br>        ensureCapacityInternal(size + 1);  // Increments modCount!!<br>        elementData[size++] = e;<br>        return true;<br>    }<br>    <br>    public E get(int index) {<br>        rangeCheck(index);<br>        checkForComodification();<br>        return ArrayList.this.elementData(offset + index);<br>    }<br>    <br>    //...省略掉其他具体的定义过程<br><br>}<br><br><br>由此,我们从源代码角度明白了为什么//1处加入Integer类型对象编译错误,且//2处get()到的类型直接就是String类型了。<br><br>我基础太薄弱,没看懂上面这些源代码,能不能用浅显易懂的文字给翻译一下</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4001202,'Digg',this)">支持(1)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4001202,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4007699" class="layer">#90楼</a><a name="4007699" id="comment_anchor_4007699"></a>  <span class="comment_date">2018-06-28 14:19</span> <a id="a_comment_author_4007699" href="http://home.cnblogs.com/u/1178738/" target="_blank">恶文</a> <a href="http://msg.cnblogs.com/send/%E6%81%B6%E6%96%87" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4007699" class="blog_comment_body">牛!!</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4007699,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4007699,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4019653" class="layer">#91楼</a><a name="4019653" id="comment_anchor_4019653"></a>  <span class="comment_date">2018-07-13 13:59</span> <a id="a_comment_author_4019653" href="http://home.cnblogs.com/u/1438512/" target="_blank">With_Her</a> <a href="http://msg.cnblogs.com/send/With_Her" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4019653" class="blog_comment_body">当Box age=new Box(123);时,这里没有定义泛型,那么编译的时候,应该是默认取得Int类型吧?</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4019653,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4019653,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4031396" class="layer">#92楼</a><a name="4031396" id="comment_anchor_4031396"></a>  <span class="comment_date">2018-07-29 23:52</span> <a id="a_comment_author_4031396" href="http://home.cnblogs.com/u/1409260/" target="_blank">ME95ZZ</a> <a href="http://msg.cnblogs.com/send/ME95ZZ" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4031396" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4031396,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4031396,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4039183" class="layer">#93楼</a><a name="4039183" id="comment_anchor_4039183"></a>  <span class="comment_date">2018-08-09 14:56</span> <a id="a_comment_author_4039183" href="https://www.cnblogs.com/glensblog/" target="_blank">MayIDoBetter</a> <a href="http://msg.cnblogs.com/send/MayIDoBetter" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4039183" class="blog_comment_body">mark怎么写</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4039183,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4039183,'Bury',this)">反对(0)</a></div><span id="comment_4039183_avatar" style="display:none;">http://pic.cnblogs.com/face/662511/20170731094326.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4054476" class="layer">#94楼</a><a name="4054476" id="comment_anchor_4054476"></a>  <span class="comment_date">2018-08-30 17:32</span> <a id="a_comment_author_4054476" href="https://www.cnblogs.com/qingo00o/" target="_blank">是阿青啊</a> <a href="http://msg.cnblogs.com/send/%E6%98%AF%E9%98%BF%E9%9D%92%E5%95%8A" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4054476" class="blog_comment_body">我他妈的赞赞赞!!!</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4054476,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4054476,'Bury',this)">反对(0)</a></div><span id="comment_4054476_avatar" style="display:none;">http://pic.cnblogs.com/face/1224615/20180502222224.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4071329" class="layer">#95楼</a><a name="4071329" id="comment_anchor_4071329"></a>  <span class="comment_date">2018-09-19 15:44</span> <a id="a_comment_author_4071329" href="http://home.cnblogs.com/u/1466375/" target="_blank">白鲟</a> <a href="http://msg.cnblogs.com/send/%E7%99%BD%E9%B2%9F" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4071329" class="blog_comment_body">似懂非懂,还需实践</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4071329,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4071329,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4078245" class="layer">#96楼</a><a name="4078245" id="comment_anchor_4078245"></a>  <span class="comment_date">2018-09-27 17:50</span> <a id="a_comment_author_4078245" href="https://www.cnblogs.com/bobobo1/" target="_blank">田然汤粉</a> <a href="http://msg.cnblogs.com/send/%E7%94%B0%E7%84%B6%E6%B1%A4%E7%B2%89" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4078245" class="blog_comment_body">懂,买了佛冷</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4078245,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4078245,'Bury',this)">反对(0)</a></div><span id="comment_4078245_avatar" style="display:none;">http://pic.cnblogs.com/face/1436539/20180707031139.png</span>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4079679" class="layer">#97楼</a><a name="4079679" id="comment_anchor_4079679"></a>  <span class="comment_date">2018-09-29 11:38</span> <a id="a_comment_author_4079679" href="https://www.cnblogs.com/guangsu/" target="_blank">光速</a> <a href="http://msg.cnblogs.com/send/%E5%85%89%E9%80%9F" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4079679" class="blog_comment_body"><a href="#3685876" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,3685876);">@</a>

衣带渐宽终不悔
这里的setDate(f)中不能用f.



	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4123606" class="layer">#98楼</a><a name="4123606" id="comment_anchor_4123606"></a>  <span class="comment_date">2018-11-27 10:48</span> <a id="a_comment_author_4123606" href="https://www.cnblogs.com/tianpeirong/" target="_blank">田培融</a> <a href="http://msg.cnblogs.com/send/%E7%94%B0%E5%9F%B9%E8%9E%8D" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4123606" class="blog_comment_body">有用!</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4123606,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4123606,'Bury',this)">反对(0)</a></div>
		</div>
	</div>

	<div class="feedbackItem">
		<div class="feedbackListSubtitle">
			<div class="feedbackManage">
				&nbsp;&nbsp;<span class="comment_actions"></span>
			</div>
			<a href="#4124269" class="layer">#99楼</a><a name="4124269" id="comment_anchor_4124269"></a><span id="comment-maxId" style="display:none;">4124269</span><span id="comment-maxDate" style="display:none;">2018/11/27 20:08:50</span>  <span class="comment_date">2018-11-27 20:08</span> <a id="a_comment_author_4124269" href="http://home.cnblogs.com/u/1542858/" target="_blank">越老越中二</a> <a href="http://msg.cnblogs.com/send/%E8%B6%8A%E8%80%81%E8%B6%8A%E4%B8%AD%E4%BA%8C" title="发送站内短消息" class="sendMsg2This">&nbsp;</a>
		</div>
		<div class="feedbackCon">
			<div id="comment_body_4124269" class="blog_comment_body">mark</div><div class="comment_vote"><a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4124269,'Digg',this)">支持(0)</a><a href="javascript:void(0);" class="comment_bury" onclick="return voteComment(4124269,'Bury',this)">反对(0)</a></div>
		</div>
	</div>
<div id="comments_pager_bottom"><div class="pager"><a href="#!comments" onclick="commentManager.renderComments(1,50);return false;">&lt; Prev</a><a href="#!comments" onclick="commentManager.renderComments(1,50);return false;">1</a><span class="current">2</span></div></div></div><script type="text/javascript">var commentManager = new blogCommentManager();commentManager.renderComments(0);</script>
</div><!--end: forFlow -->
</div>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值