I declare an enum as :
enum Sex {MALE,FEMALE};
And then, iterate enum as shown below :
for(Sex v : Sex.values()){
System.out.println(" values :"+ v);
}
I checked the Java API but can't find the values() method? I'm curious as to where this method comes from?
API link : https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html