1928/how-can-i-convert-an-arraylist-string-to-string-in-java
List<String> list = new ArrayList<String>(); String[] array = list.toArray(new String[0]);
For example:
List<String> alist = new ArrayList<String>(); alist.add("India"); alist.add("USA"); String[] stringArray = alist.toArray(new String[0]);
The toArray() method without passing any argument returns Object[].
So you have to pass an array as an argument.
In Java 8 or later:
String listString = String.join(", ", list);
In case the list is not of type String, a joining collector can be used:
String listString = list.stream().map(Object::toString).collect(Collectors.joining(", "));
Here are two ways illustrating this: Integer x ...READ MORE
Hi @Daisy You can use Google gson for more ...READ MORE
Use the lines of code mentioned below:- String ...READ MORE
String[] source = new String[] { "a", ...READ MORE
We can use external libraries: org.apache.commons.lang.ArrayUtils.remove(java.lang.Object[] array, int ...READ MORE
Yes; the Java Language Specification writes: In the Java ...READ MORE
Try this: String[] strArray = arrayList.toArray(new Str ...READ MORE
You can use this method: String[] strs = ...READ MORE
Either: Foo[] array = list.toArray(new Foo[list.size()]); or: Foo[] array = ...READ MORE
public static String reverse(String s) { ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.