public static void main(String[] args) {
int temp = -1;
String[] strs = {"aaa", "ccc", "ddd", "eee", "fff", "ggg"};
for (int i = 0; i < strs.length - 1; i++) {
if (strs[i].equals("ccc")) {
temp = i;
}
if (temp != -1) {
strs[i] = strs[++temp];
}
if (strs.length - 1 == temp) {
strs[temp] = null;
}
}
for (String q : strs) {
System.out.print(q + " ");
}
}