File tree Expand file tree Collapse file tree 1 file changed +12
-16
lines changed
docs/dataStructures-algorithms Expand file tree Collapse file tree 1 file changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ public class Main {
112
112
public static String replaceSpace (String [] strs ) {
113
113
114
114
// 如果检查值不合法及就返回空串
115
- if (! chechStrs (strs)) {
115
+ if (! checkStrs (strs)) {
116
116
return " " ;
117
117
}
118
118
// 数组长度
@@ -135,21 +135,17 @@ public class Main {
135
135
136
136
}
137
137
138
- private static boolean chechStrs (String [] strs ) {
139
- boolean flag = false ;
140
- // 注意:=是赋值,==是判断
141
- if (strs != null ) {
142
- // 遍历strs检查元素值
143
- for (int i = 0 ; i < strs. length; i++ ) {
144
- if (strs[i] != null && strs[i]. length() != 0 ) {
145
- flag = true ;
146
- } else {
147
- flag = false ;
148
- }
149
- }
150
- }
151
- return flag;
152
- }
138
+ private static boolean checkStrs (String [] strs ) {
139
+ if (strs != null ) {
140
+ // 遍历strs检查元素值
141
+ for (int i = 0 ; i < strs. length; i++ ) {
142
+ if (strs[i] == null || strs[i]. length() == 0 ) {
143
+ return false ;
144
+ }
145
+ }
146
+ }
147
+ return true ;
148
+ }
153
149
154
150
// 测试
155
151
public static void main (String [] args ) {
You can’t perform that action at this time.
0 commit comments