arraylist-String[]

String[] commands=null;
commands = new String[arrayListCommand.size()];
commands = (String[]) arrayListCommand.toArray(commands);
//可以成功cast到String数组
String[] commands=null;
commands = (String[]) arrayListCommand.toArray();
//不能cast到String数组

你可能感兴趣的:(String,ArrayList)