1.

How Can You Join Strings In Java?

Answer»

With JAVA 8 join() method has been ADDED in the String class which makes it very easy to join the multiple strings.

join method has two overloaded versions -

  • public static String join(CharSequence delimiter, CharSequence... ELEMENTS) - Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter.
  • public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) – Here elements is an Iterable that will have its elements joined together and delimiter is a sequence of characters that is used to SEPARATE each of the elements in the resulting String.

With Java 8 join() method has been added in the String class which makes it very easy to join the multiple strings.

join method has two overloaded versions -



Discussion

No Comment Found