Kfir Cohen
Kfir Cohen

Reputation: 153

Checking two chars/strings using String.contains

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

Answers (1)

Manish Doshi
Manish Doshi

Reputation: 1193

You can use String#contains() like this in your code:

  if ((String.contains("@")) && (String.contains(".com")))
    {

    }

Upvotes: 1

Related Questions