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