Convert String array to string in java
In this article, we’ll look at the String array convert to String. This can be useful for example to log query parameters.
Read Morelearn to code by examples
In this article, we’ll look at the String array convert to String. This can be useful for example to log query parameters.
Read MoreUsing Collection.toArray method First way to convert arraylist is to use built-in for every java collection method toArray(T[] ts) For example:
1 2 3 4 5 6 |
List<String> animals = new ArrayList<String>(); //add some elements animals.add("cat"); animals.add("dog"); String[] stringArray = animals.toArray(new String[0]); System.out.println(Arrays.toString(stringArray)); |
The toArray() method without any argument returns Object[]. So you have …
Read More