0
adding string condition to if statements?
String name= "Winston"; int age =22; int height=180; if (age==22&&height==180) {System.out.print("welcome";} else System.out.print("incorrect";} how do I add a condition where name needs to be "Winston" too for it to print "welcome"? thanks.
5 Respostas
+ 1
I think because its not a math operation you need name.equals() method to check a string.
0
System.out.print("welcome winston");
0
no, I mean what do I add in
if (age==22&&height==180)?
I tried (name=="Winston"&&age==22&&height==180), there was no errors, but it output was always incorrect.
0
name. equals() works thanks!