Enum In Java Example

Chapter: Data Types Last Updated: 28-04-2016 17:59:41 UTC

Program:

            /* ............... START ............... */
                
public class JavaEnumExample {

	public enum Languages {
		JAVA, COBOL, PASCAL, PHYTHON, C
	}

	public static void main(String[] args) {
		for (Languages s : Languages.values())
			System.out.println(s);
	}
}

                /* ............... END ............... */
        

Output

JAVA
COBOL
PASCAL
PHYTHON
C

Notes:

  • Enum in java is a data type that contains fixed set of constants.

Tags

Java, Enum

Similar Programs Chapter Last Updated
Java String Example Program Data Types 19-06-2016
Primitive Datatypes In Java Example Data Types 17-06-2016
Java Short Example Program Data Types 10-06-2016
Java Long Example Program Data Types 15-07-2016
Java Int Example Program Data Types 06-07-2016
Int Array In Java Example Program Data Types 09-06-2016
Java Float Program Example Data Types 28-03-2017
Java Double Example Program Data Types 28-03-2017
Java Char Example Program Data Types 28-03-2017
Java Byte Example Program Data Types 28-03-2017
Java Boolean Example Program Data Types 28-03-2017

1