title: How can I use List<object> with Integer and Float ?in java
body: <p>In fact, I want to use "normOfVector()" method with Integer, and Float, but I couldn't</p>
  
  <p>I get this error:</p>
  
  <p>The method normOfVector(ArrayList) in the type TestMethod is not applicable for the arguments (ArrayList)</p>
  
  <pre><code>    package code;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class TestMethod
  {
  
      public static float normOfVector(ArrayList&lt;Integer&gt; list)
      {
          float sum = 0.0f;
          for (Integer i : list)
              sum = sum + (float) (i * i);
          // end for
  
          return (float) Math.sqrt(sum);
      }// end function
  
  
      public static void main(String[] args)
      {
  
          // In this case no Problem
          ArrayList&lt;Integer&gt; listI = new ArrayList&lt;&gt;();
          listI.add(0);
          listI.add(3);
          listI.add(5);
          listI.add(7);
          listI.add(2);
          float result = normOfVector(listI);
  
          // In this case will not work
          ArrayList&lt;Float&gt; listF = new ArrayList&lt;&gt;();
          listF.add(0.0f);
          listF.add(3.0f);
          listF.add(5.0f);
          listF.add(7.0f);
          listF.add(2.0f);
          result = normOfVector(listF);
  
      }// end main
  
  }// end class
  </code></pre>
  
  <p>My point is:</p>
  
  <p>I want to create a method that accept the two cases.</p>
  
  <p>Thank you.</p>