StringJoiner add() method in Java Last Updated : 12 Dec, 2021 Comments Improve Suggest changes Like Article Like Report The add(CharSequence newElement) of StringJoiner adds a copy of the given CharSequence value as the next element of the StringJoiner value. If newElement is null, then "null" is added.Syntax: public StringJoiner add(CharSequence newElement) Parameters: This method takes a mandatory parameter newElement which is the element to be added.Returns: This method returns a reference to this StringJoinerBelow programs illustrate the add() method:Example 1: To demonstrate add() with delimiter " " Java // Java program to demonstrate // add() method of StringJoiner import java.util.StringJoiner; public class GFG1 { public static void main(String[] args) { // Creating StringJoiner with delimiter " " StringJoiner str = new StringJoiner(" "); // Adding elements in the StringJoiner str.add("Geeks"); str.add("for"); str.add("Geeks"); // Print the StringJoiner System.out.println(str.toString()); } } Output: Geeks for Geeks Example 2: To demonstrate add() with delimiter "," Java // Java program to demonstrate // add() method of StringJoiner import java.util.StringJoiner; public class GFG1 { public static void main(String[] args) { // Creating StringJoiner with delimiter "," StringJoiner str = new StringJoiner(","); // Adding elements in the StringJoiner str.add("Geeks"); str.add("for"); str.add("Geeks"); // Print the StringJoiner System.out.println(str.toString()); } } Output: Geeks,for,Geeks Comment More infoAdvertise with us Next Article StringJoiner add() method in Java C code_r Follow Improve Article Tags : Java Java - util package Java-Functions Java-StringJoiner Practice Tags : Java Similar Reads StringJoiner merge() method in Java The merge(StringJoiner other) of StringJoiner adds the contents of the given StringJoiner without prefix and suffix as the next element if it is non-empty. If the given StringJoiner is empty, the call has no effect.Syntax: public StringJoiner merge(StringJoiner other) Parameters: This method accepts 3 min read StringJoiner length() method in Java The length() of StringJoiner is used to find out the length of the StringJoiner in characters. It returns the length of the String representation of this StringJoiner. Note that if no add methods have been called, then the length of the String representation (either prefix + suffix or emptyValue) wi 2 min read StringBuilder append() Method in Java In Java, the append() method of StringBuilder class is used to add data to the end of an existing StringBuilder object. It supports appending different data types like strings, integers, characters, and booleans by making it easy for dynamic string manipulation.Example 1: Here, we use the append() m 4 min read StringJoiner toString() method in Java The toString() of StringJoiner is used to convert StringJoiner to String. It returns the current value, consisting of the prefix, the values added so far separated by the delimiter, and the suffix, unless no elements have been added in which case, the prefix + suffix or the emptyValue characters are 2 min read Vector add() Method in Java To add an element to a Vector in Java, you can use the add() method, which appends an element to the end of the vector.Implementation:Java// Java code to illustrate Adding // Element in Vector import java.util.*; public class GFG { public static void main(String args[]) { // Creating an empty Vector 3 min read Like