let\'s say I have this string array in java
String[] test = {"hahaha lol", "jeng jeng jeng", &quo
You can use IntStream instead. Code might look something like this:
String[] test = {"hahaha lol", "jeng jeng jeng", "stack overflow"};
IntStream.range(0, test.length).forEach(i ->
// replace non-empty sequences
// of whitespace characters
test[i] = test[i].replaceAll("\\s+", "%20"));
System.out.println(Arrays.toString(test));
// [hahaha%20lol, jeng%20jeng%20jeng, stack%20overflow]
See also: How to replace a whole string with another in an array