Looks like Malcolm covered your question well, but I just wanted to chip in here:
The .equals method is interesting. It might seem relatively basic, but actually what is going on here is a whole lot of Object-oriented goodness which you will naturally discover more about on your scripting journey
Considering inheritance, at the highest level of the hierarchy is the Object class. This implements the .equals() method (behaving the same as == I believe). All classes which inherit from the Object class will (naturally) inherit this method, and most will implement a meaningful definition of the method. For example, the String class implements a version of .equals which compares character for character.
In this case, since item.getName() returns an object of type String, calling the '.equals' method refers to the String classes equals method. As a result, the method is expecting a string and will only work with such a value. It won't know what to do with a string array.
Hopefully that clears things up - it might seem confusing at first, but give it time!
Apa