java - Replace Every 5th Character Of The Input (SPACES COUNT) -


i trying write program accept input , present input every 5th character replaced x (count spaces also). example: input: "hello name mario" outpu: "hellx xame xi maxio"

i manage replace specific letters, e.g every "m" letter.

any help?

here code you:

string test = "hello name mario";      string result = "";     int c = 1;     (int = 0; < test.length(); i++) {         if (c++==5) {             result += "x";             c = 1;         } else {             result += test.charat(i);         }     }     system.out.println("result = " + result); 

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? -