package CHAPTER09;

import java.util.Arrays;
import java.util.List;

public class C9_05_UpperBound {
	
	// 상한 제한 와일드카드: Number와 그 하위 타입만 허용
    public static double sumOfNumbers(List<? extends Number> list) {
        double sum = 0.0;
        for (Number num : list) {
            sum += num.doubleValue();
        }
        return sum;
    }

    public static void main(String[] args) {
        List<Integer> intList = Arrays.asList(1, 2, 3);
        List<Double> doubleList = Arrays.asList(1.1, 2.2, 3.3);

        System.out.println("Sum of Integer List: " + sumOfNumbers(intList));    
        System.out.println("Sum of Double List: " + sumOfNumbers(doubleList)); 
    }
}
