Amro elaswar Amro elaswar - 11 months ago 64
Java Question

change a a list inside a string to a java String[]

I have a string containing a list and by that I mean :

String list = "[\"hello\",\"everyone\"]";

How can I transform that so I can read it as a
? My question might not be very clear but please understand English is not my native language thanks everyone.

Answer Source

You can do it using replace and split methods of String class, e.g.:

String s = "[\"hello\",\"everyone\"]";
String[] split = s.replace("[", "").replace("]", "").split(",");