I am making a program where the program says "Hey!" and if the user says "hi" reply with: "What's up?" back. the problem is that the program terminated before I could even type my input. I am really confused. I tried other stack posts but that did not work. Please help! Relevant code:
import java.util.*;
class Main {
public static void main(String[] args) {
System.out.println("Hey!");
Scanner sc = new Scanner(System.in);
if (sc.equals("hi")) {
System.out.println("Whats up?");
}
sc.close();
}
}
If there is any way to shorten the code or make it more efficient please include that too.