gpt4 book ai didi

groovy - 将 int 数组的字符串表示形式转换为常规列表

转载 作者:行者123 更新时间:2023-12-01 08:05:41 25 4
gpt4 key购买 nike

如果我得到一个字符串,它是一个 int 数组的表示,如下所示
String d = "[2,3,4,5]"
我如何转换为字符串数组?
String[] f = convert d to array of String
另外我如何转换为int数组?

int[] f = convert d to array of int

最佳答案

我正在寻找其他解决方案,因为我的值包含字符串,其中包含点和 found this .

此代码应该适合您:

"[1,2,3]".tokenize(',[]')*.toInteger()

关于groovy - 将 int 数组的字符串表示形式转换为常规列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17207272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com