I am parsing 100 of files which contains 1000 of lines in it.
I have to check whether line starts with some keywords.
i have 2 options not sure which to consider.
option 1:
String[] keywordsArr = { "Everything", "Think", "Result", "What", "#Shop", "#Cure" };
for (int i = 0; i < linesOfCode.length; i++) {
for (String keyWord : keywordsEndingAtEndOfLogicalLine) {
if (linesOfCode[i].indexOf(keyWord) > -1) {
if (linesOfCode[i].trim().startsWith(keyWord)) {
linesOfCode[i] = "";
break;
}
}
}
}
option 2:
String[] keywordsArr = { "Everything", "Think", "Result", "What", "#Shop", "#Cure" };
for (int i = 0; i < linesOfCode.length; i++) {
for (String keyWord : keywordsArr) {
if (linesOfCode[i].trim().startsWith(keyWord)) {
linesOfCode[i] = "";
break;
}
}
}
frequency of line starting with Keywords is 1 in 100.
Try using continue instead of break. Instead of stopping the loop, continue will tell the program to go one level up, thus continuing the loop for the next item.