Created
May 23, 2021 14:57
-
-
Save walidum/d09a69ff2e732799ec315037ef480f72 to your computer and use it in GitHub Desktop.
Collection to an Array
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
//Demo.java | |
public static String[] collectiontoArray() { | |
var sampleList = Arrays.asList("Algiers", "Setif"); | |
return sampleList.toArray(String[]::new); | |
} | |
//DemoTest.java | |
@Test | |
public void collectiontoArrayTest() { | |
assertTrue(Arrays.equals(Demo.collectiontoArray(), new String[]{"Algiers", "Setif"})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment