The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to Iterate over Java Enum using values and for loop

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 436
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to Iterate over Java Enum using values and for loop Posted: Mar 4, 2013 9:06 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to Iterate over Java Enum using values and for loop
Feed Title: Java67
Feed URL:
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

In this Java programming tutorial, we will learn how to iterate over enum in Java. Since Enums are collection of finite number of objects, often we need to iterate over them. Enums are also final in Java and has private constructor, which means you can not create enum instances once declared. Iteration over Enum is extremely simple, provided you know about implicit values() method, which is a static method, provided by java.lang.Enum. Since every enum in Java extends java.lang.Enum, they all get this implicit values() method. Actually there are couple of them, e.g. valueOf(), name(), ordinal() etc.In last couple of Java tutorials on enum we have seen How to convert Enum to String in Java, Enum valueOf Example and Enum Constructor Example. This tutorial focuses on iteration over Enum in Java.

Read: How to Iterate over Java Enum using values and for loop

Topic: Using twitter4j with Play! Framework and Secure Social is this easy Previous Topic   Next Topic Topic: JVM performance optimization, Part 5: Is Java scalability an oxymoron?

Sponsored Links


Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us