Java if statement strings and more
- by user1820578
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.