在 Android 中,没有直接的包含方法,但可以使用 String 类的 contains() 方法来判断一个字符串是否包含另一个字符串。例如:

String str1 = 'Hello world'; String str2 = 'world'; if (str1.contains(str2)) { // str1包含str2 } else { // str1不包含str2 }

本方法简单易用,适用于各种场景下的字符串包含判断。

Android 字符串包含判断:contains() 方法使用

原文地址: https://www.cveoy.top/t/topic/kyEU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录