java - Find Positions of Multiple Occurrences of a Character in a String -


if have string line = "xyztgexgxrx", line.indexof("x"); returns index of first "x" contained in string.

what want know, what allow me second "x", or occurrence of "x" after that?

answer can found here: java indexof method multiple matches in string

there second parameter indexof sets start parameter. code example prints indices of x

i = str.indexof('x'); while(i >= 0) {      system.out.println(i);      = str.indexof('x', i+1); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -