Cast ArrayList <String> to String [] in one expression?
I have a constructor that accepts an ArrayList<String> , but wants to call super , expecting an array of String[] .
I tried the following, but this results in a class exception, [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
public cool(ArrayList<String> s) { super((String[]) s.toArray()); } I would like to go cool a ArrayList<String>
thanks
EDIT: I tried a recent suggestion to use
super(s.toArray(new String[s.size()])); but now I get the following exception:
entity must have a no-arg constructor.; nested exception is java.lang.IllegalArgumentException: : entity must have a no-arg constructor.
+4