title: Detect if an array contains integer or double
body: <p>I'm working on a project that requires me to have a string representation of an array. The problem is having this duplicated code, that I'm sure can be refactored in some way, but I haven't found one yet.</p>
  
  <pre><code>private static String printDoubleArray(String title, double[] array){
      String result = title;
      for (double d : array) {
          result += d + " ";
      }
      return result;
  }
  
  private static String printIntArray(String title, int[] array){
      String result = title;
      for (int d : array) {
          result += d + " ";
      }
      return result;
  }
  </code></pre>
  
  <p>Thanks in advance.</p>