How to create a string from a Java Array?

You can convert an array of Strings to a single array using the collect() method.

Example

import java.util.Arrays;
import java.util.stream.Collectors;

public class CreatngStringFromArray {
   public static void main(String args[]) {

      String [] myArray = {"Welcome", "to", "Tutorialspoint"};
      String str = Arrays.stream(myArray).collect(Collectors.joining(" "));
      System.out.println(str);
   }
}

Output

Welcome to Tutorialspoint
Updated on: 2026-03-11T23:14:17+05:30

462 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements