I wanted to convert the `Arraylist <String>` to array `double` and i used the following code:

```
String [] n = (String[]) lines.toArray();

String[] array = lines.toArray(new String[lines.size()]);

double[] nums = new double[n.length];
for (int i= 0 ; i< nums.length; i++){
      nums[i] = Double.parseDouble(n[i]);

```

but then i have the following error:

```
Exception in thread "main" java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lang.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap')

```

could anybody help me?