Как сравнить String и Char?
Выдает ошибку Incompatible operand types String and char
for(index = 0; index < User.length(); index++) {
char[] morsec = User.toCharArray();
for(int i = 0; i < morsec.length;i++){
for(int j = 0; j < word.length;j++){
if(`word[j] == morsec[i]`) {
answer = answer + morze[j] + " ";
}
}
}
}
Ответы (1 шт):
Автор решения: Алексей Шиманский
→ Ссылка
word.charAt(i) == morsec[i]
или
word[j].equals(new String(new char[]{morsec[i]}));