Java Program to Get the Length of String Constructed by Stringjoiner Class

You are currently viewing Java Program to Get the Length of String Constructed by Stringjoiner Class

Java program to get the length of string Constructed by StringJoiner class

// Java program to get the length of string Constructed 
// by StringJoiner class

import java.util.*;

public class Main {
  public static void main(String[] args) {
    StringJoiner str = new StringJoiner(",");

    str.add("ABC");
    str.add("LMN");
    str.add("PQR");
    str.add("XYZ");

    System.out.println("Constructed String is: '" + str + "'");
    System.out.println("Length of string is: " + str.length());
  }
}

Output

Constructed String is: 'ABC,LMN,PQR,XYZ'
Length of string is: 15

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply