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 {
112112 public static String replaceSpace (String [] strs ) {
113113
114114 // 如果检查值不合法及就返回空串
115- if (! chechStrs (strs)) {
115+ if (! checkStrs (strs)) {
116116 return " " ;
117117 }
118118 // 数组长度
@@ -135,21 +135,17 @@ public class Main {
135135
136136 }
137137
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+ }
153149
154150 // 测试
155151 public static void main (String [] args ) {
You can’t perform that action at this time.
0 commit comments