How can I do VALIDATIONS of 3 chains of STRINGS in Java Netbeans? [closed]

0

I have two classes Instrument (contains instrument names) and Musician (contains Instrument, musical name and position) The validation that I have to relate is: If the name of the musician does not correspond to his instrument and his position print error. Apart I must validate that they are all members.

To compare only two Strings in another exercise I used the following: String string1 = new String ("Hello"); String string2 = new String ("Hello"); if (string1.equals (string2)) {    ... }

up there all right, but I do not know how to put the third strings. I thought about using an else but I do not know how to save the first comparison as a single string.

    
asked by Erick 29.07.2018 в 04:06
source

1 answer

0

Remember that the equals() method returns a boolean (that is, with values true or false ). You can build an expression using boolean operators as & & amp; (and) and || (or)

if ( uno.equals(dos) && dos.equals(tres) ) {
   :
}
    
answered by 29.07.2018 / 07:01
source