We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d89b396 commit b137d79Copy full SHA for b137d79
problems/剑指Offer05.替换空格.md
@@ -134,7 +134,8 @@ public static String replaceSpace(StringBuffer str) {
134
//使用 sb 逐个复制 str ,碰到空格则替换,否则直接复制
135
for (int i = 0; i < str.length(); i++) {
136
//str.charAt(i) 为 char 类型,为了比较需要将其转为和 " " 相同的字符串类型
137
- if (" ".equals(String.valueOf(str.charAt(i)))){
+ //if (" ".equals(String.valueOf(str.charAt(i)))){
138
+ if (s.charAt(i) == ' ') {
139
sb.append("%20");
140
} else {
141
sb.append(str.charAt(i));
0 commit comments