Khalil Saboor před 8 roky
rodič
revize
969b841788
1 změnil soubory, kde provedl 19 přidání a 2 odebrání
  1. 19
    2
      StringArrayUtils.java

+ 19
- 2
StringArrayUtils.java Zobrazit soubor

152
      * @return array with identical contents excluding values of `value`
152
      * @return array with identical contents excluding values of `value`
153
      */ // TODO
153
      */ // TODO
154
     public static String[] removeValue(String[] array, String valueToRemove) {
154
     public static String[] removeValue(String[] array, String valueToRemove) {
155
+        StringBuilder sb = new StringBuilder();
155
         
156
         
157
+        //Looping through array
158
+        for(int index = 0;index < array.length;index++){
159
+            //if the array value does not equal
160
+            //the value to remove, then add the values to a temp array
161
+           
162
+            if(array[index] != valueToRemove ){
163
+             sb.append(array[index] + "~");
164
+                
165
+            }
166
+            
167
+            
168
+        }
169
+        String answer = sb.toString();
156
         
170
         
157
-        
158
-        return null;
171
+        String [] temp = answer.split("~");
172
+        return temp;
159
     }
173
     }
160
 
174
 
161
     /**
175
     /**
163
      * @return array of Strings with consecutive duplicates removes
177
      * @return array of Strings with consecutive duplicates removes
164
      */ // TODO
178
      */ // TODO
165
     public static String[] removeConsecutiveDuplicates(String[] array) {
179
     public static String[] removeConsecutiveDuplicates(String[] array) {
180
+        
181
+        
182
+        
166
         return null;
183
         return null;
167
     }
184
     }
168
 
185