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.
This is the Error that shows up:
Ass10.java:148: error: no suitable method found for toArray(double[])
rtrn = s.toArray(rtrn);
Here is the 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<Double> s = new HashSet<Double>();
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;
}