Created
September 2, 2015 10:54
-
-
Save xtea/6194d799fe5338631811 to your computer and use it in GitHub Desktop.
Collection convert to array in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Collection; | |
public class CollectionToArray { | |
public static void main(String[] args) { | |
Collection<String> collection = new ArrayList<String>(); | |
collection.add("jack"); | |
collection.add("john"); | |
collection.add("jason"); | |
String[] array = new String[collection.size()]; | |
collection.toArray(array); | |
System.out.println(array); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment