Help with my traffic light program
When I type in 'green' at the prompt 'Enter your traffic light colour:', 'GO' is not output. Can anyone help.
Code:
package testing;
import java.util.Scanner;
public class trafficlight {
public static void main(String[] args) {
Scanner Scanner1 = new Scanner (System.in);
System.out.println("Enter your traffic light colour:");
String userinput = Scanner1.nextLine();
//Testing the user input from the Scanner
if (userinput == "green"){
System.out.println("GO");}
else if (userinput == "amber"){
System.out.print("GET READY");}
else if (userinput == "red"){
System.out.print("STOP");}
}
}