Which statement will iterate through Direction?

Given: Which statement will iterate through Direction?

Given: Which statement will iterate through Direction?

A.
for (Direction d : Direction.asArray()){ // }

B.
for (Direction d : Direction.values()){ // }

C.
for (Direction d : Direction.asList()){ // }

D.
for (Direction d : Direction.iterator()){ // }



Leave a Reply 2

Your email address will not be published. Required fields are marked *


leo yu

leo yu

public enum Direction{
East(1),West(2),South(3),North(4);
int value=0;
Direction(int value){
this.value = value;
}
}

public class Tester{
public static void main(String[] args){
for(Direction d: Direction.values()){
System.out.println(d.value);
}
}

}