# substring()

say it: **“SUB-string”** **/ˈsʌbˌstrɪŋ/**

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?category=java&level=2)

Updated: November 17, 2026

## In other subjects

- [Substring() in C#](https://www.ask-codey.com/glossary/substring-c-sharp)

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