title: incompatible types object cannot be converted to Number
body: <p>I am trying to compile the below code but getting "incompatible types object cannot be converted to Number at <code>for(Number n:list)</code>.</p>
  
  <pre><code>import java.util.*;
  
   class Output
    {
      public static double sumOfList(List list)
      {
          double s=0.0;
  
          for(Number n:list)
              s+=n.doubleValue();
  
          return s;
      }
  
      public static void main(String[] args) 
      {
          List li=Arrays.asList(1,2,3);
          System.out.println(SumOfList(li));
      }
    }
  </code></pre>