Ниже приведен метод из 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, скажем, Boolean, и мы поставляем Callable<Boolean>
в качестве первого параметра, каков тип возвращаемого метода? Это Boolean, ScheduledFuture<Boolean>
или что-то еще?
Пожалуйста, кто-то, распакуйте это для меня.
Это '' ScheduledFuture. Первый '' просто называет новую общую переменную. –