diff --git a/src/test/java/org/chulk/sanxbox/TestSnippets.java b/src/test/java/org/chulk/sanxbox/TestSnippets.java new file mode 100644 index 0000000..a826cf6 --- /dev/null +++ b/src/test/java/org/chulk/sanxbox/TestSnippets.java @@ -0,0 +1,24 @@ +package org.chulk.sanxbox; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +public class TestSnippets { + + @Test + public void testStringConcat() { + String[] strings = { "apple", "banana", "cherry", "date" }; + String delimiter = ","; + String firstDelimiter = ":"; + + String joinedString = Arrays.stream(strings) + .findFirst() + .map(s -> s + firstDelimiter + Arrays.stream(strings).skip(1).collect(Collectors.joining(delimiter))) + .orElse(""); + + System.out.println(joinedString); + } + +} \ No newline at end of file