title: Why use printf("%s") for arguments passed to generic methods?
body: <pre><code>package genericMethods;
  
  public class OverloadedMethods {
  
      /**
       * @param args
       */
      public static void main(String[] args) {
          // TODO Auto-generated method stub
  
          Integer[] integerArray = {1, 2, 3, 4, 5};
          Double[] doubleArray = {1.0, 2.0, 3.0, 4.0, 5.0};
          Character[] charArray = {'a', 'b', 'c', 'd'};
  
          System.out.println("A has: ");
          printArray(integerArray);
          System.out.println("B has: ");
          printArray(doubleArray);
          System.out.println("C has: ");
          printArray(charArray);
      }
  
      public static &lt;T&gt; void printArray(T[] array)
      {
          for(T element : array)
              System.out.printf("%s ", element);//why use %s instead of others? 
  
          System.out.println();
      }
  
  }
  </code></pre>
  
  <p>My question is the method printArray() doesn't know what type of data is going to print out, and seems %d will occur error at run time - but isn't %s for String only ? </p>