I am new to programming and need help with a bit of code I wrote.
This is what I have so far:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner Scan = new Scanner(System.in);
System.out.println("The program is starting, please be patient...");
System.out.println("Do you want to start the program? (y/n):");
String input = Scan.nextLine();
if (input == "y") {
System.out.println("Hello World!");
}
else {
System.out.println("Error");
System.out.println(input + " not recognized!");
}
}
}
When I run this, there are no errors, but when I type "y" it runs the else section instead of saying "Hello World!". How can I make it so when I type in "y" it says "Hello World!"?