Tuesday, 16 August 2016

java - I cannot find the logic error in this conditional statement. I don't exactly know where my logic is incorrect

I have the following statement...




personName[0] = n[y].getName().equals ("Penny") ? personName[0]++ : personName[0];


personName[] is an integer array. getName returns a string. Every time getName is equal to "Penny," I want personName[0] to add one. How should I do this? When I run it, personName[0] does not add one and I don't know why.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...