[Solved] a method that recieves String input and divides it into 1,2 and 3 different sections


Here is an example how you can do that. I hope if you are not a beginner you know about ArrayList.

String word = "water";
ArrayList<String> list = new ArrayList<String>();
for (int i = 1; i <= 3; i++) {
    int limit = word.length() - i + 1;
    for (int j = 0; j < limit; j++) {
        list.add(word.substring(j, j+i));
    }
}
System.out.println(list);

Output :

[w, a, t, e, r, wa, at, te, er, wat, ate, ter]

Try to understand it. and tell me if having any doubt.

1

solved a method that recieves String input and divides it into 1,2 and 3 different sections