I am trying to take a scanner input for a variable named site and set another variable, emr, to one of 3 possible values based on what was input for site.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
String site = read.nextLine();
if (site == "site1"){
String emr = "sampletext";
} else if (site == "site2"){
String emr = "domain";
} else {
String emr = " ";
}
System.out.print(emr);
}
}
Is there a way I can make this work? My understanding of Java is (clearly) limited at best, I started very recently.