【发布时间】:2026-01-31 11:10:01
【问题描述】:
注意:无需更新此问题即可。我想了个办法自己解决。
这是我目前所拥有的:
public static String splitStringUserNumb(String message, int x){
String result= "";
//Something I have to do here but not sure how I can approach the problem
int countToSplit = 0;
for(int i =0; i < text.length(); i){
if(countToSplit == SplitStringNum){
result+= text.substring(i,)
}
countToSplit++;
}
return result;
}
【问题讨论】:
-
您需要一个循环,获取大小为
x的子字符串,直到字符串的长度小于x。 -
我试过但不知道怎么做,这就是我有的,我会把它放在那里
-
你应该向我们展示你以前的代码,这样我们可以给你一些建议
-
首先你应该声明
SplitStringNum。然后你必须添加一个不同的条件来拆分你的字符串,然后再次重置你的计数器 -
或者在这里发布你对问题的回答。