From 910484e88fb47d8dd338a508137281b216a233d8 Mon Sep 17 00:00:00 2001 From: notme Date: Tue, 4 Jul 2023 22:58:29 +0200 Subject: [PATCH] Add test snippets class. --- .../java/org/chulk/sanxbox/TestSnippets.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/test/java/org/chulk/sanxbox/TestSnippets.java 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