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.
当我收集一个字符串时,我期望它是ittype 的char,但它是java.lang.String. 那么为什么会这样?如何收集字符串的所有字符?
it
char
java.lang.String
你可以做这样的事情......
someString.collect { def c = it as char // carry on... }
或者...
someString.chars.collect { // it will be a char // carry on... }
在 Groovy 中,单个字符也是一个字符串。为了将每个字符串作为字符使用:
"testString".collect { it as char }