+ 1

help with java

Does anyone know why this code doesn't output hi if the input is hello import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner a = new Scanner(System.in); if(a.next() == "hello"){ System.out.println("hi"); } } }

21st Jun 2017, 7:00 AM
Daan van IJcken
Daan van IJcken - avatar
1 Answer
+ 4
if(a.next().equals("hello")){ System.out.println("hi"); }
21st Jun 2017, 7:05 AM
Мг. ĐšĐœĐ°ĐżđŸŒ 
Мг. ĐšĐœĐ°ĐżđŸŒ  - avatar