title: How do I restrict accepting only one type in my generic method?
body: <p>I have a generic function foo, which accepts any type and prints them out.</p>
  
  <pre><code>public static &lt;T&gt; T foo(T... arg) {
      List&lt;T&gt; foo = Arrays.asList(arg);
      for (T t : foo) {
        System.out.println(t);
      }
      return null;
    }
  </code></pre>
  
  <p>How do I make sure that the arguments received are of only 1 type. For example, {1,'a',3} should be invalid. It should either be all numbers or all characters. I want to accept either ALL integers or ALL Characters.</p>