泛型方法
-----------siwuxie095
泛型方法中可以定义泛型参数,此时参数的类型就是传入的数据类型
格式:
 
		
代码:
| package com.siwuxie095.generic; 
 
 class GenX{ 
 //泛型方法 public <T>T tell(T t){ return t; } 
 } 
 public class GenericDemo06 { 
 public static void main(String[] args) { GenX g=new GenX(); //String str=g.tell("siwuxie095"); System.out.println(g.tell("siwuxie095")); //int i=g.tell(10); System.out.println(g.tell(10)); } 
 } | 
运行一览:
 
		
【made by siwuxie095】
posted on 2017-03-19 00:20 siwuxie095 阅读(121) 评论(0) 收藏 举报

 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号 
