Friday, 2 May 2014

Enum : toString : Get the name of this enum constant

public String toString()
Returns the name of this enum constant, as contained in the declaration.

enum Day{
 MON,
 TUE,
 WED,
 THU,
 FRI,
 SAT,
 SUN;
 
 public static void main(String args[]){
  for(Day d1 : Day.values()){
   System.out.println(d1.toString());
  }
 }
}

Output
MON
TUE
WED
THU
FRI
SAT
SUN


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment