What is the meaning of the <?> token in Java?

前端 未结 8 1811
囚心锁ツ
囚心锁ツ 2020-12-18 01:47

What is the meaning of the token in this code copied from www.JavaPractices.com? When I replace it with the more conventional looking

8条回答
  •  猫巷女王i
    2020-12-18 02:30

    Assuming this.executorService is a subtype of ScheduledExecutorService (available since Java 1.5), the return type of scheduleWithFixedDelay() is ScheduledFuture. You can't change the return type from ScheduledFuture to ScheduledFuture, ScheduledFuture or anything else for that matter. You could, however, change it to just ScheduledFuture since is a wildcard generic type parameter that approximates a raw type for backward compatibility.

    See What is a raw type and why shouldn't we use it? for a good discussion on raw types and generics.

提交回复
热议问题