Java.util.StringJoiner in Java8

Java 8Object Oriented ProgrammingProgramming

This class is used Join a sequence of characters separating using the delimiter.

Example

public class StringJoinerSample {
   public static void main(String[] args){
      StringJoiner sj = new StringJoiner(", ");
      sj.add("Krishna");
      sj.add("Raju");
      sj.add("Satish");
      sj.add("Pruthvi");
      System.out.println(sj);
   }
}

Output

Krishna, Raju, Satish, Pruthvi
raja
Published on 05-Jul-2019 10:38:47
Advertisements