Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
public static int mystery(int[] array) {
int i = 0;
int count = 0;
while (i <= array.length) {
if (array[i] %2 == 0) {
count++;
}
i++;
}
return count;
}
public static String mystery(String input) {
String tricky = "";
for (int i = 0; i < input.length(); i++) {
tricky = tricky + input.charAt(i);
i++;
tricky = tricky + input.charAt(i);
}
return tricky;
}
Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[
^]
ultraedit[
^]