Popular Tutorials
Start Learning JavaCertification Courses
Created with over a decade of experience and thousands of feedback.
Python online compiler
JavaScript online compiler
SQL online compiler
Java online compiler
HTML online compiler
C online compiler
C++ online compiler
C# online compiler
PHP online compiler
Swift online compiler
Kotlin online compiler
TypeScript online compiler
Go online compiler
Rust online compiler
Scala online compiler
Dart online compiler
R online compiler
Ruby online compiler
Java Program to Implement switch statement on strings
In this example, we will learn to implement the switch statement on strings in Java.
To understand this example, you should have the knowledge of the following Java programming topics:
Example: Implement the switch statement on Strings
// Java Program to implement String on switch statements in Java
class Main {
public static void main(String[] args) {
// create a string
String language = "Java";
switch(language) {
case "Java":
System.out.println(language + " is famous for enterprise applications.");
break;
case "JavaScript":
System.out.println(language + " is famous for frontend and backend.");
break;
case "Python":
System.out.println(language + " is famous for ML and AI.");
break;
default:
System.out.println(language + " not found on record.");
break;
}
}
}
Output
Java is famous for enterprise applications.
In the above example, we have implemented the switch statement on Strings. This feature was introduced in Java 7.
Did you find this article helpful?