Replace certain string in array of strings

后端 未结 7 974
广开言路
广开言路 2021-01-12 22:07

let\'s say I have this string array in java

String[] test = {"hahaha lol", "jeng jeng jeng", &quo         


        
7条回答
  •  甜味超标
    2021-01-12 22:35

    Here's a simple solution:

    for (int i=0; i < test.length; i++) {
        test[i] = test[i].replaceAll(" ", "%20");
    }
    

    However, it looks like you're trying to escape these strings for use in a URL, in which case I suggest you look for a library which does it for you.

提交回复
热议问题