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.
有人可以通过传递一组索引来帮助我获得一个字符串并把它分成 N 块...
例如
索引集 = (0,3,7,10);
并通过这些索引来制动一个字符串
我怎样才能做到这一点?
谢谢
我会尝试用循环来做。
for (int i = 0; i < indexes.length; i++) { if (i == indexes.length -1) { string.substring(indexes[i]); } else { string.substring(indexes[i], indexes[i+1]); } }
将子字符串捕获到某个适当的容器中(列表或数组,取决于)