mardi 26 septembre 2017

How to compare a character or two to another character or two [on hold]

I've written a for-loop that iterates through a large string and its goal is to see if my string has characters like $ or $$. This is the if statement that I have inside my for-loop:

if (stringName.charAt(i) == "$" || stringName.charAt(i) == "$$")

When I compile my code, I get an error saying "incomparable types: char and String" which is self explanatory. Now my question is, what is the best way to fix it? What method apart from charAt() can I use to compare the two characters string "$$"?

Aucun commentaire:

Enregistrer un commentaire