gpt4 book ai didi

java - 在java中压缩字符串列表

转载 作者:行者123 更新时间:2023-11-29 10:02:25 26 4
gpt4 key购买 nike

压缩与此类似的字符串列表的最简单/最快的方法是什么:

john,barry,stewart,josh,30,45,23,56

我想要的顺序是

john,30,barry,45,stewart,23,josh,56

我知道这听起来像是家庭作业,但实际列表用于某些 selenium 代码并存储 url 和页面上的单选按钮选项,但我认为上面的示例更易于阅读。

最佳答案

我会做类似的事情:

String[] parts = input.split(",");
int halfLength = parts.length / 2;
for (int i = 0; i < halfLength; i++) {
String name = parts[i];
String age = parts[i + halfLength];
// Store them in whatever structure you want here
}

关于java - 在java中压缩字符串列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20213070/

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