我尝试在网上寻找解决这个问题的方法,但没有找到任何东西。
我编写了以下抽象代码来解释我的问题:
String text = "how are you?";
String[] textArray= text.splitByNumber(4); //this method is what I'm asking
textArray[0]; //it contains "how "
textArray[1]; //it contains "are "
textArray[2]; //it contains "you?"
方法splitByNumber将字符串"text"每4个字符分割一次。我该如何创建这个方法?
非常感谢