Moudiz Moudiz - 1 year ago 49
Java Question

get count of string with commas and split them

I am new to java . I have this String.


I want to make a loop and send the data . the below is wrong but i want something similar to it.

for ( int i = 0; i>str.length; i++)
// i know it wrong but I want to get the result before comma, for example first loop plane, second loop cat third loop red and so on

Answer Source

This should be what you are looking for:

String str="plane,cat,red,dogy";
for(String subString: str.split(",")){