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.