substring()

A String method that returns part of an existing string.

What does substring() do in Java?

substring() — A String method that returns part of an existing string.

class Order {
    String numberFrom(String orderId) {
        return orderId.substring(4);
    }
}

Level: Apprentice · More Java terms at this level

Updated