title: usage of generic in Callable and Future interface?
body: <p>What's the use of generic in <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/Callable.html" rel="nofollow noreferrer"><code>Callable</code></a> interface?</p>
  <p>Consider this code which I copied from <a href="https://blogs.oracle.com/CoreJavaTechTips/entry/get_netbeans_6" rel="nofollow noreferrer">https://blogs.oracle.com/CoreJavaTechTips/entry/get_netbeans_6</a>:</p>
  <pre><code>import java.util.\*;
  import java.util.concurrent.\*;
  
  public class CallableExample {
  
    public static class WordLengthCallable
          implements Callable {
      private String word;
      public WordLengthCallable(String word) {
        this.word = word;
      }
      public Integer call() {
        return Integer.valueOf(word.length());
      }
    }
  
    public static void main(String args[]) throws Exception {
      ExecutorService pool = Executors.newFixedThreadPool(3);
      Set&lt;Future&lt;Integer&gt;&gt; set = new HashSet&lt;Future&lt;Integer&gt;&gt;();
      for (String word: args) {
        Callable&lt;Integer&gt; callable = new WordLengthCallable(word);
        Future&lt;Integer&gt; future = pool.submit(callable);
        set.add(future);
      }
      int sum = 0;
      for (Future&lt;Integer&gt; future : set) {
        sum += future.get();
      }
      System.out.printf(&quot;The sum of lengths is %s%n&quot;, sum);
      System.exit(sum);
    }
  }
  </code></pre>
  <p>Integer in <code>Callable&lt;Integer&gt;</code> and <a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/Future.html" rel="nofollow noreferrer"><code>Future&lt;Integer&gt;</code></a> is not being used. It could be anything else as well like <code>Callable&lt;String&gt;</code> and <code>Future&lt;String&gt;</code> and code will still work.</p>
  <p>I understand usage of Generics and appreciates its usage specially in collections.</p>
  <p>Thanks.</p>