 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Implement Switch on Enum in Java
Enum in Java contains a fixed set of constants. They can have fields, constructors and method. It enhances type safety in Java.
The following is an example wherein we are implementing Switch statement on Enumeration in Java −
Example
public class Demo {    public static void main(String[] args) {       Laptop l = Laptop.Inspiron;       switch(l){          case Inspiron:          System.out.println("Laptop for home and office use!");             break;          case XPS:           System.out.println("Laptop for the ultimate experience!");             break;          case Alienware:           System.out.println("Laptop for high-performance gaming");             break;       }    } } enum Laptop {       Inspiron, XPS, Alienware; }  Output
Laptop for home and office use!
Advertisements
 