Vote count: 0
I only want the first element from s.split(",")
and I need to return value to be in a String array.
How can I make this code a one liner?
String [] sd = s.split(",");
String [] sf = new String[]{sd[0]};
I tried s.split(",",1);
but it just adds it all to the first element without actually splitting it.
asked 20 secs ago
This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.
Java - Better way to split a string into just one array
Aucun commentaire:
Enregistrer un commentaire