English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Dans cet exemple, nous allons apprendre à implémenter une instruction switch sur les chaînes de caractères en Java.
Pour comprendre cet exemple, vous devriez comprendre ce qui suitJava programmingTopic:
//Implement String in Java-on-switch statement class Main { public static void main(String[] args) { // Create a string String language = "Java"; switch(language) { case "Java": System.out.println(language + "Famous for enterprise applications."); break; case "JavaScript": System.out.println(language + "Famous for front-end and back-end."); break; case "Python": System.out.println(language + "Famous for ML and AI."); break; default: System.out.println(language + "Not found record."); break; } } }
Output result
Java is famous for enterprise applications.
In the above example, we implemented the switch statement on the string. Java 7This function was introduced in the middle.