function - Can somebody explain how does this program regarding enum works in java? -


here's code :

enum status {      status_open(10),     status_started(11),     status_inprogress(12);      private final int status;      status(int astatus) {         this.status = astatus;     }      public int getstatus() {         return this.status;     }  }  class statustest3 {      public static void main(string[] args) {          (status stat : status.values()) {             system.out.println(stat + " value " + stat.getstatus());         }     } } 

what status.values() return ?

and output :

status_open value 10 status_started value 11 status_inprogress value 12 

http://docs.oracle.com/javase/7/docs/api/java/lang/enum.html

all constants of enum type can obtained calling implicit public static t[] values() method of type.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -