# 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.

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

Level: Apprentice · [More Java terms at this level](https://www.ask-codey.com/glossary/subjects/java/apprentice)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/substring
