瀏覽代碼

one method left

mpierse 6 年之前
父節點
當前提交
ffd0f5c1dc
共有 1 個文件被更改,包括 12 次插入2 次删除
  1. 12
    2
      src/main/java/com/zipcodewilmington/StringArrayUtils.java

+ 12
- 2
src/main/java/com/zipcodewilmington/StringArrayUtils.java 查看文件

@@ -152,9 +152,19 @@ counter++;
152 152
      * @return array of Strings with consecutive duplicates removes
153 153
      */ // TODO
154 154
     public static String[] removeConsecutiveDuplicates(String[] array) {
155
+        String[] tempArr = new String[array.length];
156
+        int counter = 0;
157
+        for (int i=0; i<array.length-1; i++){
158
+            if (array[i].equals(array[i+1])){
159
+                continue;
160
+            } else {
161
+                tempArr[counter++]=array[i];
162
+            }
163
+           // int decrement = tempArr.indexOf(null);
164
+        }
155 165
 
156
-        
157
-
166
+        System.out.print(tempArr);
167
+return array;
158 168
     }
159 169
 
160 170
     /**