Search

Java - Conver a List into an Array and vice versa

2014-11-09 1:56 PM
Examples
// List to Array
Foo[] array = list.toArray(new Foo[list.size()]);

// in Java 8
String[] strings = list.stream().toArray(String[]::new);

//Array to List
List list = Arrays.asList( array );

// or
List list = Arrays.asList( "value1", "value2", "value3" );

No comments:

Post a Comment