DEV Community

Sandeep kamboj
Sandeep kamboj

Posted on

3

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]);

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay