DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Array To List An Vice Veras

05.28.2005
| 203521 views |
  • submit to reddit
        Convert an array to a list.

List<Date> listOfDates = Arrays.asList(arrayOfDates);

On the fly list construction:

List<Date> listOfDates = Arrays.asList(new Date[]{date1, date2});

Convert a list into an array:

Date[] arrayOfDates = listOfDates.toArray(new Date[]{});
    

Comments

Snippets Manager replied on Wed, 2009/11/18 - 6:38pm

// or saving 1 character ;) Date[] arrayOfDates = listOfDates.toArray(new Date[0]);