当前位置: 移动技术网 > 移动技术>移动开发>Android > android 之 Java 泛型通配符T的使用

android 之 Java 泛型通配符T的使用

2018年02月08日  | 移动技术网移动技术  | 我要评论

1. 泛型通配符T的使用

public class Apple {
    private String appleName = "apple_";
    private static int index = 0;

    public String myName()
    {
        appleName += index;
        return appleName;
    }
}
public class Box {
    private T object;

    public void set(T inObj)
    {
        this.object = inObj;
    }

    public T get()
    {
        return object;
    }
}
Box appleBox = new Box();
appleBox.set(new Apple());
Apple theApple = appleBox.get();


如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网