< Prev
Next >

Enums in Java

A Java Enumeration(Enums) defines a class type through which we can define a list of constants. By default, these constants are public, static and final.

Features of Enums

Creating a simple enumeration.

// Enumeration example

enum Cities{ 
Frankfurt, NewYork, Sydney, Tokyo		//enumeration constants

class A
public static void main(String... ar)
Cities c= Cities.Sydney;



Output is :


Program Analysis

Please Subscribe

Please subscribe to our social media channels for daily updates.

Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page


Please check our latest addition