title: Java HashSet to array
body: <p>I'm trying to convert a HashSet to an Array of Doubles. Yes I have a main method and class defined, I've just included what I've imported as well as the code for this specific function.</p>
  
  <p>This is the Error that shows up:</p>
  
  <pre><code>Ass10.java:148: error: no suitable method found for toArray(double[])
                  rtrn = s.toArray(rtrn);
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>import java.util.List;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Set;
  import java.util.HashSet;
  
  
  public static double[] negated(double[] a) {
          Set&lt;Double&gt; s = new HashSet&lt;Double&gt;();
          for(double x : a) {
              s.add(x);
          } for(double x : s) {
              if(s.contains(-x) == false) {
                  s.remove(x);
              }
          }
          double[] rtrn = new double[s.size()];
          rtrn = s.toArray(rtrn);
          return rtrn;
          }
  </code></pre>