Advertisement
thenewboston

Java Programming Tutorial - 45 - EnumSet range

Aug 22nd, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.EnumSet;
  2.  
  3. public class apples {
  4.    public static void main(String[] args){
  5.       for(tuna people: tuna.values())
  6.          System.out.printf("%s\t%s\t%s\n", people, people.getDesc(), people.getYear());
  7.            
  8.       System.out.println("\nAnd now fpr the range of constants!!!\n");
  9.      
  10.       for(tuna people: EnumSet.range(tuna.kelsey, tuna.candy))
  11.       System.out.printf("%s\t%s\t%s\n", people, people.getDesc(), people.getYear());
  12.    }
  13. }
  14.  
  15. public enum tuna {
  16.    bucky("nice", "22"),
  17.    kelsey("cutie", "10"),
  18.    julia("bigmistake", "12"),
  19.    nicole("italian", "13"),
  20.    candy("different", "14"),
  21.    erin("iwish", "16");
  22.    
  23.    private final String desc;
  24.    private final String year;
  25.    
  26.    tuna(String description, String birthday){
  27.       desc = description;
  28.       year = birthday;
  29.    }
  30.    
  31.    public String getDesc(){
  32.       return desc;
  33.    }
  34.    
  35.    public String getYear(){
  36.       return year;
  37.    }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement