0

I'm trying to make my program output go or slow down if the light is green or yellow, but for some reason it will only output the else statement. I'm not sure what part of my code needs to be modified and could really use some help. Please and thank you.

import java.util.Scanner;
class hello{
    public static void main(String[]args){
        Scanner text = new Scanner(System.in);
        String color = text.nextLine();
        if(color == "green"){
            System.out.println("Go!");
        }
        else if(color == "yellow"){
            System.out.println("Slow down!");
        }
        else{
            System.out.println("Stop!");
        }
      
    }
}
jahbarri
  • 29
  • 3

0 Answers0