Changed words replace from while to for

This commit is contained in:
Frank Baumann 2014-05-05 12:38:03 +02:00
parent a2cb93fc6a
commit c7a4a36699

View File

@ -228,14 +228,13 @@ public class Words {
}
// remove all "from" and split "words" there
String[] splitted = words.split(from);
int index = 0;
String part;
// if there are occurences of "from"
if (splitted.length > 1) {
// - 1 because dont add "to" to the end of last part
while (index < splitted.length - 1) {
part = splitted[index];
for (int i = 0; i < splitted.length - 1; i++) {
part = splitted[i];
// add current part of "words" to the output
newWords = newWords + part;
// check if the part ends with correct string
@ -247,10 +246,10 @@ public class Words {
// add original
newWords = newWords + from;
}
index++;
}
// add the last part to finish the sentence
part = splitted[index];
part = splitted[splitted.length - 1];
if (part.equals(" ")) {
// dont add the space to the end
return newWords;
@ -298,5 +297,4 @@ public class Words {
}
}
}
}