Str.Substring (0, 5) Renvoie une sous-chaîne de 0 à 4 index (inclus) de la chaîne.

class scratch{
    public static void main(String[] args) {
        String hey = "Hello World";
        System.out.println( hey.substring(0, 5) );
        // prints Hello;
    }
}
Nitbit25