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.
我有一个值的arrayListdef list = ['a', 'e', 'u', 'o', 'A', 'E', 'O', 'U'];
def list = ['a', 'e', 'u', 'o', 'A', 'E', 'O', 'U'];
如何查找该列表中是否包含某个字符?我试过contains了,但没有用。总是返回false。
contains
false
def char = 'a' println(list.contains(char));
char是 Groovy(和 Java)中的关键字,该列表也包含字符串。
char
尝试这个:
def list = ['a', 'e', 'u', 'o', 'A', 'E', 'O', 'U'] def s = 'a' println list.contains( s )