mardi 29 novembre 2016

Can I use Logical Operators && || with Strings?

For example, I was trying to create an if statement requiring both conditions entered in a scanner to be true. I know it's possible with numbers.

if(input2.equals("yes"))   
// and adding (input1.equals(chooseOpt[1])) to the same statement. 
// if this and that is true  all written in the same statement 
// then print out etc...etc... 

I'm on my way to becoming better at Java but I want to know, is this possible? And if so, how?

Aucun commentaire:

Enregistrer un commentaire