-1

How to convert String[] to String in Java without using for loop ?

I know how to convert using for loop but I want to convert it without using any loop (for or while).

Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
Mahesh Narayanan
  • 123
  • 5
  • 21

2 Answers2

3

Use Arrays.toString() to convert it.

Returns a string representation of the contents of the specified array. If the array contains other arrays as elements, they are converted to strings by the Object.toString() method inherited from Object, which describes their identities rather than their contents.

Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
0

Arrays.toString()

Example

String[] arr = new String[2];
arr[0] = "Str 1"; arr[1] = "Str 2";
System.out.println(Arrays.toString(arr));
Soumitri Pattnaik
  • 3,246
  • 4
  • 24
  • 42