Browse Source

Add test snippets class.

master
notme 1 year ago
parent
commit
910484e88f
  1. 24
      src/test/java/org/chulk/sanxbox/TestSnippets.java

24
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);
}
}
Loading…
Cancel
Save