Lookup the API documentation of class ArrayList. You'll see that there are two toArray() methods: one that takes no arguments and returns an Object[], and one that does take an argument T[] and returns T[]. You need to use the second toArray() method:
String[] s = (String[]) l.toArray(new String[l.length]);