package com.test.generic;
//泛型类
public class Box<T> {
private T t;
public T getT() {
return t;
}
public void setT(T t) {
this.t = t;
}
public Box(T t)
{
this.t=t;
}
}
泛型接口
java复制代码
package com.test.generic;
//泛型接口
public interface MyList<E> {
E next();
}
java复制代码
package com.test.generic;
public class MyArrayList implements MyList<String>{
@Override
public String next() {
// TODO Auto-generated method stub
return null;
}
}