str.SubString (0, 5) Zwraca podłoże od 0 do 4 indeksów (włącznie) ciągu.

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