title: How to convert linkedlist to array using `toArray()`?
body: <p>I do not know how to convert a linked list of doubles to array. Please help me find the error.</p>
  
  <pre><code>import java.util.*;
  public class StackCalculator {
  
  
    private   LinkedList&lt;Double&gt; values;
    double value1 , value2 ;
  
    public StackCalculator()
    {
       values = new LinkedList&lt;Double&gt;();
    }
  
  
      void push(double x)
      {
           values.addFirst(x);
      }
      double pop()
      {
         return values.removeFirst();
      }
      double add()
      {
          value1=pop();
          value2=pop();
          return (value1 + value2);
      }
  
      double mult()
      {
          value1=pop();
          value2=pop();
          return (value1 * value2);
      }
  
  
      double[] v = new double[10];
      double[] getValues()
      {
          return   values.toArray(v);
      }
  
  }
  </code></pre>