0

I don't get why my code isn't working

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner text = new Scanner(System.in); String word = text.nextLine(); String hello = "Hello"; if (word==hello){ System.out.println("Hi!"); } } }

8th Jul 2017, 2:08 PM
Giorgi Gogelashvili
Giorgi Gogelashvili - avatar
1 Odpowiedź
+ 7
Use if (word.equals(hello)) instead of == 🖒
8th Jul 2017, 2:17 PM
J.G.
J.G. - avatar