0
下面是java.util.concurrent.ScheduledExecutorService方法:需要帮助理解这个通用声明
/**
* Creates and executes a ScheduledFuture that becomes enabled after the
* given delay.
*
* @param callable the function to execute
* @param delay the time from now to delay execution
* @param unit the time unit of the delay parameter
* @return a ScheduledFuture that can be used to extract result or cancel
* @throws RejectedExecutionException if the task cannot be
* scheduled for execution
* @throws NullPointerException if callable is null
*/
public <V> ScheduledFuture<V> schedule(Callable<V> callable,
long delay, TimeUnit unit);
为什么会出现<V> ScheduledFuture<V>
?
这看起来像乍一看像方法上的两个返回类型。所以,如果V是,让我们说布尔,并且我们提供Callable<Boolean>
作为第一个参数,该方法的返回类型是什么?是布尔,ScheduledFuture<Boolean>
还是别的?
请有人给我解开这个。
这是'ScheduledFuture'。第一个''只是命名新的通用变量。 –
2014-11-21 21:34:57