Split string to equal length substrings in Java

后端 未结 21 2151
日久生厌
日久生厌 2020-11-22 02:56

How to split the string \"Thequickbrownfoxjumps\" to substrings of equal size in Java. Eg. \"Thequickbrownfoxjumps\" of 4 equal size should give th

21条回答
  •  醉梦人生
    2020-11-22 03:16

    Another brute force solution could be,

        String input = "thequickbrownfoxjumps";
        int n = input.length()/4;
        String[] num = new String[n];
    
        for(int i = 0, x=0, y=4; i

    Where the code just steps through the string with substrings

提交回复
热议问题