I do not know how to convert a linked list of doubles to array. Please help me find the error.
import java.util.*;
public class StackCalculator {
private
The problem is the type of your list, which is Double
(object), while you're trying to return an array of type double
(primitive type). Your code should compile if you change getValues()
to return a Double[]
.
For your other methods, it's not a problem, because Java automatically converts Double
s to double
s and back (called autoboxing). It cannot do that for array types.