Computer Science, asked by abhinav98324, 2 months ago

No matter what i type in input it always shows the else statement, ie, What to sayyyy???...

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner Kira=new Scanner (System.in);
System.out.println("Are you Abhinav???");
String a= Kira.next();
String b= "yes";
String c= "No";
if (a==b)
{ System.out.println ("Welcome...");
}
else if (a==c)
{ System.out.println("Don't dare to open me again...");}
else {
System.out.println ("What to sayyyy???");}
}
}

Answers

Answered by ajb7899
1

Answer:

the problem is that you are using == relational operator

where the string function equals() should be used

Explanation:

if further confusion most welcome to ask

Similar questions