[Solved] Java else if and scanner [closed]


You should use == to copmare not use = and ; after if statment not correct.

You can see the code after edit like this:

    import java.util.Scanner; 
    class Test{ 
    public static void main(String args[]){
    Scanner sc=new Scanner(System.in); 
     System.out.println("Pick option:\n 1-Option one\n 2-Option two :");
     int x= sc.nextInt();
    if (x==1)
    {
    System.out.println("You select option one");
    }
    else if(x==2){
            System.out.println("You select option two");
    }
    else{
    System.out.println("Please select option one or two by typing 1 or 2");
}                 

    } 
    }

solved Java else if and scanner [closed]