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
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
History,
1 month ago
Social Sciences,
1 month ago
English,
2 months ago
Math,
2 months ago
Computer Science,
10 months ago
Math,
10 months ago