title: How can you write a function that accepts multiple types?
body: <p>I have a function that should work on int[] and on String[] now i have made the same function with a int parameter and an String parameter however if it has to go this way its a bit copy paste work and doesn't look very organized is there a way to solve this and put these 4 functions in 2?</p>
  
  <pre><code>    static public void print(String s)
      {
          System.out.println(s);
      }
  
      static public void print(int s)
      {
          System.out.println(s);
      }
  
      static public void printArray(String[] s)
      {
          for (int i=0; i&lt;s.length; i++)
              print(s[i]);
      }
  
      static public void printArray(int[] s)
      {
          for (int i=0; i&lt;s.length; i++)
              print(s[i]);
      }
  </code></pre>
  
  <p>Thanks
  Matthy</p>