Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
使用 String.contains 时是否可以一次检查两个字符?
我说的是这样的事情:
if (String.contains("@" && ".com")) { Toast.makeText(this, "This is an E-mail Address!", Toast.LENGTH_LONG).show(); return true; }
我试过这样做,但是没有成功并寻找替代方法。
您可以在代码中像这样使用 String#contains() :
if ((String.contains("@")) && (String.contains(".com"))) { }