< 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 our social media channels for notifications, we post a new article everyday.

Decodejava Google+ Page Decodejava Facebook Page  DecodeJava Twitter Page

Coming Next
C++ and Python