Java 5.0 ·ºÐÍÖ® Java·ºÐͽӿÚ
package Demo;
// Java·ºÐͽӿÚ
interface Info24<T> { // ÔÚ½Ó¿ÚÉ϶¨Òå·ºÐÍ
public T getVar(); // ¶¨Òå³éÏó·½·¨£¬³éÏó·½·¨µÄ·µ»ØÖµ¾ÍÊÇ·ºÐÍÀàÐÍ
}
class InfoImp24<T> implements Info24<T> { // ¶¨Òå·ºÐͽӿڵÄ×ÓÀà
private T var; // ¶¨ÒåÊôÐÔ
public InfoImp24(T var) { // ͨ¹ý¹¹Ôì·½·¨ÉèÖÃÊôÐÔÄÚÈÝ
this.setVar(var);
}
public void setVar(T var) {
this.var = var;
}
public T getVar() {
return this.var;
}
}
public class GenericsDemo24 {
public static void main(String arsg[]) {
Info24<String> i = null; // ÉùÃ÷½Ó¿Ú¶ÔÏó
i = new InfoImp24<String>("it"); // ͨ¹ý×ÓÀàʵÀý»¯¶ÔÏó
System.out.println("Length Of String : " + i.getVar().length());
}
}
package Demo;
// Java·ºÐͽӿÚ
interface Info25<T> { // ÔÚ½Ó¿ÚÉ϶¨Òå·ºÐÍ
public T getVar(); // ¶¨Òå³éÏó·½·¨£¬³éÏó·½·¨µÄ·µ»ØÖµ¾ÍÊÇ·ºÐÍÀàÐÍ
}
class InfoImp25 implements Info25<String> { // ¶¨Òå·ºÐͽӿڵÄ×ÓÀà
private String var; // ¶¨ÒåÊôÐÔ
public InfoImp25(String var) { // ͨ¹ý¹¹Ôì·½·¨ÉèÖÃÊôÐÔÄÚÈÝ
this.setVar(var);
}
public void setVar(String var) {
this.var = var;
}
public String getVar() {
return this.var;
}
}
public class GenericsDemo25 {
// ¸ÃÅú×¢µÄ×÷ÓÃÊǸø±àÒëÆ÷Ò»ÌõÖ¸Á¸æËßËü¶Ô±»Åú×¢µÄ´úÂëÔªËØÄÚ²¿µÄijЩ¾¯¸æ±£³Ö¾²Ä¬¡£
/*
* @description "deprecation" ʹÓÃÁ˲»ÔÞ³ÉʹÓõÄÀà»ò·½·¨Ê±µÄ¾¯¸æ
*
* @description "unchecked" Ö´ÐÐÁËδ¼ì²éµÄת»»Ê±µÄ¾¯¸æ£¬ÀýÈ統ʹÓü¯ºÏʱûÓÐÓ÷ºÐÍ (Generics)
* À´Ö¸¶¨¼¯ºÏ±£´æµÄÀàÐÍ¡£
*
* @description "fallthrough" µ± Switch ³ÌÐò¿éÖ±½ÓͨÍùÏÂÒ»ÖÖÇé¿ö¶øûÓÐ Break ʱµÄ¾¯¸æ¡£
*
* @description "path" ÔÚÀà·¾¶¡¢Ô´Îļþ·¾¶µÈÖÐÓв»´æÔڵķ¾¶Ê±µÄ¾¯¸æ¡£
*
* @description "serial" µ±ÔÚ¿ÉÐòÁл¯µÄÀàÉÏȱÉÙ serialVersionUID ¶¨ÒåʱµÄ¾¯¸æ¡£
*
* @description "finally" ÈκΠfinally ×Ӿ䲻ÄÜÕý³£Íê³ÉʱµÄ¾¯¸æ¡£
*
* @description "all" ¹ØÓÚÒÔÉÏËùÓÐÇé¿öµÄ¾¯¸æ¡£
*/
@SuppressWarnings("unchecked")
public static void main(String arsg[]) {
Info25 i = null; // ÉùÃ÷½Ó¿Ú¶ÔÏó
i = new
Ïà¹ØÎĵµ£º
Java´úÂëʵÏÖÒÀÀµ×¢Èë
2009-01-15 08:18:55
¡¡±êÇ©£ºÒÀÀµ×¢Èë¡¡¡¡¡¡[ÍÆË͵½¼¼ÊõȦ]
°æȨÉùÃ÷£ºÔ´´×÷Æ·£¬ÔÊÐíתÔØ£¬×ªÔØʱÇëÎñ±ØÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕ Ôʼ³ö´¦ ¡¢×÷ÕßÐÅÏ¢ºÍ±¾ÉùÃ÷¡£·ñÔò½«×·¾¿·¨ÂÉÔðÈΡ£http://zhangjunhd.blog.51cto.com/113473/126545
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#de ......
¹¹½¨¸ßÐÔÄܵÄJ2EEÓ¦Óò»µ«ÐèÒªÁ˽ⳣÓõÄʵʩ¼¼ÇÉ¡£ÏÂÃæ½éÉÜ×î³£ÓõÄ10ÖÖÓÐЧ·½·¨£¬¿É°ïÖú¼Ü¹¹Éè¼ÆʦÃÇ¿ìËÙ³ÉΪÕâ·½ÃæµÄר¼Ò¡£
JavaÐÔÄܵĻù´¡—ÄÚ´æ¹ÜÀí
ÈκÎJavaÓ¦Ó㬵¥»úµÄ»òJ2EEµÄÐÔÄÜ»ù´¡¶¼¿É¹é½áµ½ÄãµÄÓ¦ÓÃÊÇÈçºÎ¹ÜÀíÄÚ´æµÄÎÊÌâ¡£JavaµÄÄÚ´æ¹ÜÀí°üÀ¨Á½¸öÖØÒªÈÎÎñ£ºÄÚ´æµÄ·ÖÅäºÍÄÚ´æµÄ»ØÊÕ¡£ÔÚÄÚ´æµÄ·ÖÅäÖУ¬Ä ......
package Demo;
// ÊÜÏÞ·ºÐÍ
class Info17<T> {
private T var; // ¶¨Òå·ºÐͱäÁ¿
public void setVar(T var) {
this.var = var;
}
public T getVar() {
return this.var;
}
public String toString() { // Ö±½Ó´òÓ¡
return this.var.toString();
}
}
public class GenericsDemo17 {
publ ......
ÔÌûµØÖ·£ºhttp://www.hengxinsoft.com/2009/07/ubuntu%E4%B8%8Bjava%E7%8E%AF%E5%A2%83%E7%9A%84%E6%90%AD%E5%BB%BA/
°²×°
´ò¿ªÖնˣºÊäÈëÃüÁî:
sudo apt-get install sun-java6-jdk
Ìáʾ£º°²×°¹ý³ÌÖÐÐèÒªÄã»Ø´ðÊÇ·ñͬÒâʹÓÃÐÒ飨ÖÕ¶ËÖкìÀ¶É«µÄÌáʾ½çÃ棩£¬´Ëʱ°´tab¼üÖÁOK£¬ÔÙ°´»Ø³µ¼´¿ÉÕý³£°²×°
´ý°²×°Íê±ÏºóÑ¡Ôñ ......