Reputation: 153
Is it possible to check two chars at once when using String.contains?
I am speaking of something like this:
if (String.contains("@" && ".com"))
{
Toast.makeText(this, "This is an E-mail Address!", Toast.LENGTH_LONG).show();
return true;
}
I have tried doing it this way, However with no success and looking for an alternative.
Upvotes: 0
Views: 104
Reputation: 1193
You can use String#contains() like this in your code:
if ((String.contains("@")) && (String.contains(".com")))
{
}
Upvotes: 1