Java – StringJoiner Class

Java StringJoiner Class methods, constructors, variables available in Java 8 release are listed below. We will publish example program on each methods ASAP.

Constructors in Java StringJoiner Class

S.No Constructor & Description
1 StringJoiner(CharSequence delimiter)

Constructs a StringJoiner with no characters in it, with no prefix or suffix, and a copy of the supplied delimiter.
2 StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix)

Constructs a StringJoiner with no characters in it using copies of the supplied prefix, delimiter and suffix.

Methods in Java StringJoiner Class

S.No Method & Description
1 StringJoiner add(CharSequence newElement)

Adds a copy of the given CharSequence value as the next element of the StringJoiner value.
2 int length()

Returns the length of the String representation of this StringJoiner.
3 StringJoiner merge(StringJoiner other)

Adds the contents of the given StringJoiner without prefix and suffix as the next element if it is non-empty.
4 StringJoiner setEmptyValue(CharSequence emptyValue)

Sets the sequence of characters to be used when determining the string representation of this StringJoiner and no elements have been added yet, that is, when it is empty.
5 String toString()

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 returned

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. Java – Spliterators.AbstractLongSpliterator Class
  2. Java – SortedSet Interface
  3. Java – Collections Class
  4. Java – LongToIntFunction Interface
  5. Java – Delayed Interface
  6. Java – Base64.Decoder Class
  7. Java – ObjDoubleConsumer Interface
  8. Java – DoubleSummaryStatistics Class
  9. Java – StringTokenizer Class
  10. Java – Spliterators Class
  11. Java – BiConsumer Interface
  12. Java – RunnableFuture Interface
  13. Java – ForkJoinPool.ManagedBlocker Interface
  14. Java – ThreadLocalRandom Class
  15. Java – Runnable Interface

Be the first to comment

Leave a Reply