collection and array

Collection to array

  1. Object[]

    1
    Object[] listArray = list.toArray();
  2. specific array

    1
    String[] listArray = (String[]) list.toArray(new String[0])

ps. it’s can’t be used to translate generic paradigm typed array

Array to collection

1
2
List list = new ArrayList();
list = Arrays.asList(array);

ps. primary type can’t do it like this, it’s parameter must be objects