title: How to read arrays from command line and display them using generic method in JAVA?
body: <p>I'm  working on something related to generics in java and I've found this example on the internet <a href="http://www.tutorialspoint.com/java/java_generics.htm" rel="nofollow">here</a>. This might be a simple question but I want to find a correct answer from someone who worked with generics. This generic method takes as input argument different types of arrays and displays them. Now I want to do this by reading those arrays from command line. Can you please help me find the correct way to do it? Thanks.</p>
  
  <pre><code>public class GenericMethodTest
      {
         // generic method printArray                         
         public static &lt; E &gt; void printArray( E[] inputArray )
         {
            // Display array elements              
               for ( E element : inputArray ){        
                  System.out.printf( "%s ", element );
               }
               System.out.println();
          }
  
          public static void main( String args[] )
          {
              // Create arrays of Integer, Double and Character
              Integer[] intArray = { 1, 2, 3, 4, 5 };
              Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4 };
              Character[] charArray = { 'H', 'E', 'L', 'L', 'O' };
  
              System.out.println( "Array integerArray contains:" );
              printArray( intArray  ); // pass an Integer array
  
              System.out.println( "\nArray doubleArray contains:" );
              printArray( doubleArray ); // pass a Double array
  
              System.out.println( "\nArray characterArray contains:" );
              printArray( charArray ); // pass a Character array
          } 
      }
  </code></pre>