# switch Statement

A statement that selects a code path by matching one value against cases.

## What does **switch Statement** do in Java?

**switch Statement** — A statement that selects a code path by matching one value against cases.

```java
class Shirt {
    String sizeName(String size) {
        return switch (size) {
            case "M" -> "Medium";
            default -> "Other";
        };
    }
}
```

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

Updated: September 27, 2026

## In other subjects

- [switch Statement in JavaScript](https://www.ask-codey.com/glossary/switch-statement-javascript)

Source: https://www.ask-codey.com/glossary/switch-statement
