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.
class Shirt {
String sizeName(String size) {
return switch (size) {
case "M" -> "Medium";
default -> "Other";
};
}
}
Level: Novice · More Java terms at this level
Updated