Help us understand the problem. What is going on with this article?

Mediumで見つけた for-eachとenum絡めたループ

More than 5 years have passed since last update.

https://medium.com/on-coding/3fcb28e30ef3

for (MyEnem<variable-name>:MyEnum.values()){

Statements

}
enum Day {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY}

とまあこのように列挙しておいて

for (Day d : Day.values()){
    System.out.print(d);
    System.out.print(" is day number");
    System.out.println(d.ordinal());
    // System.out.println(d + " is day number" + d.ordinal())
}

ordinal()でordinal number(序数、番号数)を取得できる

http://docs.oracle.com/javase/jp/1.5.0/api/java/lang/Enum.html
より

ordinal
public final int ordinal()
列挙定数の序数 (列挙宣言での位置。初期定数はゼロの序数に割り当てられる) を返します。このメソッドは、ほとんどのプログラマにとって役に立ちません。このメソッドは、EnumSet と EnumMap などの洗練された enum ベースのデータ構造で使用するために設計されています。
戻り値:
この列挙定数の序数

「ほとんどのプログラマにとって役に立ちません」ワロタw

http://www.atmarkit.co.jp/ait/articles/1103/03/news107_2.html

ここら辺も参考に。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした