String gleicheBuchstaben(String wort1, String wort2) {
StringBuilder b = new StringBuilder();
int n = Math.min(wort1.length(), wort2.length());
for (int i = 0; i < n; i++) {
char ch = wort1.charAt(i);
if (ch == wort2.charAt(i)) {
b.append(ch);
}
}
return b.toString();
}
int n = Math.min(wort1.length(), wort2.length());
for (int i = 0; i < n; i++) {
char ch = wort1.charAt(i);
if (ch == wort2.charAt(i)) {
b.append(ch); // hier result += ..
}
}
String result = "";
...
result += char;
...