Java if statement strings and more
Posted
by
user1820578
on Stack Overflow
See other posts from Stack Overflow
or by user1820578
Published on 2012-11-13T10:57:42Z
Indexed on
2012/11/13
10:59 UTC
Read the original article
Hit count: 253
I have decided to try and learn a little in java tonight and i have just been trying some stuff with things i have learned.
My question is in an if statement how to i make two stings to be true. Here is what i have so far.
if ("male".equals(gender)) && ("brendan".equals(name))
the problem i am pretty sure is the && but i am not sure.
also my other question is with gender it should either be male or female. I want to have if statement with male and another for female. For this do i just do another if. For eg
if ("male".equals(gender)) && ("brendan".equals(name))
{
System.out.println("blah blah");
}
else
{
System.out.println(" wrong wrong");
}
if ("female".equals(gender))
{
System.out.println("blah blah2");
}
else
{
System.out.println(" wrong wrong 2");
}
hope that makes sense. Any help would be great.
© Stack Overflow or respective owner