DEV Community 👩‍💻👨‍💻

Sandeep kamboj
Sandeep kamboj

Posted on

Convert ArrayList<String>() To Stirng[] Array in Android

ArrayList list=new ArrayList<>();
list.add("A");
list.add("B");
list.add("C");
list.add("D");

String[] stringArr=TextUtils.join(",",list).split(",");

Top comments (1)

Collapse
 
ibibgor profile image
Oscar

Isn't it more performant to use the buildin method toArray(). So the code would be:

List<String> list = new ArrayList<>();
// add some data
String[] starr = list.toArray(new String[0]);

Update Your DEV Experience Level:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠