概述
使用
1 //定义一个泛型类: 2 public class ClassName<T>{ 3 private T data; 4 5 public T getData() { 6 return data; 7 } 8 9 public void setData(T data) { 10 this.data = data; 11 } 12 }
1 public interface IntercaceName<T>{ 2 T getData(); 3 }
1 public class Interface1 implements IntercaceName<String> { 2 private String text; 3 @Override 4 public String getData() { 5 return text; 6 } 7 }
1 public class Interface1<T> implements IntercaceName<T> { 2 private T data; 3 @Override 4 public T getData() { 5 return data; 6 } 7 }
1 private static <T> T 方法名(T a, T b) {}
1 <T extends 类或接口1 & 接口2>
作用
注意
原文:https://www.cnblogs.com/zhangzhongkun/p/14408944.html