Code dnt work. "cannot be resolved to a variable" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Code dnt work. "cannot be resolved to a variable"

In my Code there is Always the same Problem "lösung cannot be resolved to a variable" And i have no other idea how to fix it. I hope that someone of you can help me: public static void main(String[] args) { // 1. Ausgabe String chars = "abcdefghijklmnopqrstuvwxyzäöüß.,:;?-_()'=+/@"; Random rnd = new Random(); char buchstabe = chars.charAt(rnd.nextInt(chars.length())); // Eingabe Scanner scan = new Scanner(System.in); System.out.println("Was ist der Morsecode von: " + buchstabe); String antwort = scan.nextLine(); scan.close(); System.out.println(antwort); // Berechnung der Lösung if (buchstabe == 'a') { char lösung = '.'; } else { System.out.println("False"); } // Ausgabe if (antwort == lösung) { System.out.println("True"); } else { System.out.println("False"); } }

11th Aug 2019, 8:31 AM
Peter Möhle
Peter Möhle - avatar
0 Answers