# switch Statement

*noun*

say it: **“switch STAYT-ment”** **/swɪtʃ ˈsteɪtmənt/**

Code that picks one of several paths by matching a single value against a list of 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";
        };
    }
}
```

## In a sentence

- “I used a **switch statement** on the menu choice, with one case for each option from 1 to 4.”

Level: Novice · [More Java terms at this level](https://www.ask-codey.com/glossary?category=java&level=1)

Updated: October 26, 2026

## In other subjects

- [switch Statement in C#](https://www.ask-codey.com/glossary/switch-statement-c-sharp)
- [switch Statement in JavaScript](https://www.ask-codey.com/glossary/switch-statement-javascript)
- [switch Statement in PowerShell](https://www.ask-codey.com/glossary/switch-statement-powershell)

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