Java tutorial
//package com.java2s; import java.util.ArrayList; public class Main { private static ArrayList<String> getThreegramm(String word) { ArrayList<String> result = new ArrayList<>(); if (word.length() > 2) { for (int i = 0; i < word.length() - 2; i++) { result.add(Character.toString(word.charAt(i)) + Character.toString(word.charAt(i + 1)) + Character.toString(word.charAt(i + 2))); } } return result; } }