Array to list an vice veras   Leave a comment

Convert an array to a list.

List listOfDates = Arrays.asList(arrayOfDates);

On the fly list construction:

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

Convert a list into an array:

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

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

Posted 2010年11月21日 by gw8310 in 未分类

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: