Tokenize a string: Difference between revisions

Content added Content deleted
(→‎{{header|Go}}: small update for library change)
(→‎{{header|Java}}: Updated the for-loop to use the proper variable name (words - not word).)
Line 597: Line 597:
String words[] = toTokenize.split(",");//splits on one comma, multiple commas yield multiple splits
String words[] = toTokenize.split(",");//splits on one comma, multiple commas yield multiple splits
//toTokenize.split(",+") if you want to ignore empty fields
//toTokenize.split(",+") if you want to ignore empty fields
for(int i=0; i<word.length; i++) {
for(int i=0; i<words.length; i++) {
System.out.print(word[i] + ".");
System.out.print(words[i] + ".");
}</lang>
}</lang>