The contains method can be used if you want to check if a string contains certain characters. It's fairly simple to use. Here's an example:
After the contains method, you type a pair of round brackets. In between the round brackets, you type the text you're checking for. In our code, we're using an if statement. If it's true that the string contains a "-" character, then some code can be executed.
No comments:
Post a Comment