1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| package enumSet;
import java.util.EnumSet; import java.util.Set;
public class Test2 { public enum Style { BOLD, ITALIC, UNDERLINE, STRIKETHROUGH }
private Set<Style> retSet;
public void applyStyles(Set<Style> styles) { this.retSet = styles; }
public void showStyle() { for (Style temp : retSet) System.out.println("현재 지정된 스타일 : " + temp.name()); }
public static void main(String[] args) { Test2 t = new Test2(); t.applyStyles(EnumSet.of(Style.BOLD, Style.ITALIC)); t.showStyle(); } }
|