IT/Programming
<Effective Java> RULE 27 가능하면 제네릭 메서드로 만들 것
제네릭 메서드? 제네릭 메서드는 매개 타입과 리턴 타입으로 타입 파라미터를 갖는 메소드를 말합니다. public 리턴 타입 메소드명(매개변수, ...) { ... } // 제네릭 메서드 public static Set union(Set s1, Set s2){ Set result = new HashSet(s1); result.addAll(s2); return result; } // 제네릭 메서드 용례 public static void main(String[] args){ Set guys = new HashSet( Arrays.asList("Tom", "Dick", "Harray")); Set stooges = new HashSet( Arrays.asList("Larry", "Moe", "Culy")); S..
2023. 4. 27. 09:27