- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java break statement with switch
Following is an example
Example
public class Test { public static void main(String args[]) { // char grade = args[0].charAt(0); char grade = 'C'; switch(grade) { case 'A' : System.out.println("Excellent!"); break; case 'B' : case 'C' : System.out.println("Well done"); break; case 'D' : System.out.println("You passed"); case 'F' : System.out.println("Better try again"); break; default : System.out.println("Invalid grade"); } System.out.println("Your grade is " + grade); } }
Output
Compile and run the above program using various command line arguments. This will produce the following result −
Well done Your grade is C
- Related Articles
- How to use PowerShell Break statement with the Switch command?
- Java switch statement with multiple cases.
- Java switch statement
- Switch Statement in Java
- Java switch statement example
- Can we use Switch statement with Strings in java?
- PHP break Statement
- PHP switch Statement
- Java Program to Implement switch statement on strings
- Break Statement in C/C++
- What is PowerShell Break statement?
- Break statement in Dart Programming
- Break statement in Lua Programming
- Kotlin 'when' statement vs Java 'switch'
- How to use PowerShell Break statement with the While Loop?

Advertisements