
最近在学习 netty,但是某些泛型的高级用法没人教的话感觉看不懂。比如这样的
package io.netty.util; /** * Holds {@link Attribute}s which can be accessed via {@link AttributeKey}. * * Implementations must be Thread-safe. */ public interface AttributeMap { /** * Get the {@link Attribute} for the gven {@link AttributeKey}. This method will never return null, but may return * an {@link Attribute} which does not have a value set yet. */ <T> Attribute<T> attr(AttributeKey<T> key); /** * Returns {@code} true if and only if the given {@link Attribute} exists in this {@link AttributeMap}. */ <T> boolean hasAttr(AttributeKey<T> key); } 在 boolen 之前的<T>是啥意思,有达人知道么?
求教
1 dallaslu 2019-03-11 17:00:19 +08:00 就是范型的声明啊,在方法的返回值前声明的,意思是这是一个范型方法。 |
2 leonard916 2019-03-11 19:29:15 +08:00 声明后面的泛型 |
3 xueyingbing 2019-03-11 21:48:33 +08:00 泛型方法,建议系统性看一下泛型,就会了解了。 如果不了解的话,也可以暂时忽略,不影响。 |