public enum Coffee{
thileban("nice", "26"), (Objects, description, year)
tara("disaster", "21"),
farwa("bigmistake","19");
private final String desc; (Description)
private final String year;
Coffee (String description, String birthday){ (Enumeration Constructor)
desc = description;
year = birthday;
}
public String getDesc () {
return desc;
}
public String getYear() {
return year;
}
}
public class apples{
public static void main(String args[]) {
for(Coffee people: Coffee.values())
System.out.printf("%s\t%s\t%s\n",people,people.getDesc(), people.getYear());(return the string of year and description)
}
}
(Enhanced for loop)
Comments
Post a Comment