How to get first value of a String with split delimiter?

Hi

I have a String v = "3,6,8,10";
How can I get the value '3' and '8'?


v.split("\\,") //how to use it to get the value?

Open in new window

techquesAsked:
Who is Participating?
 
Bart CremersConnect With a Mentor Java ArchitectCommented:
split returns a String array, so

String[] s = v.split("\\,");

System.our.println(s[0]);
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.