How to convert arraylist to array of strings

Pls let me know the convertion of arraylist to array of strings

I found this, toArray().
A sample.

public static String[] getNames() throws Exception

      ArrayList al = new ArrayList();

      String str [] = (String []) al.toArray (new String [al.size ()]);
      return str;

The comments above assume that you are defining an ArrayList of Strings, or, at least, the objects you are storing in the ArrayList are Strings.