# Map + List combining collections
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class cc
{
public static void main(String[] args)
{
Map<String, List<Integer>> testScores = new HashMap<>();
List<Integer> mikeScores = new ArrayList<>();
mikeScores.add(80);
mikeScores.add(60);
mikeScores.add(50);
testScores.put("mike", mikeScores);
printScores("mike", testScores);
}
public static void printScores(String studentName, Map<String, List<Integer>> scoreMap)
{
List<Integer> scores = scoreMap.get(studentName);
for (int score : scores)
{
System.out.println(score);
}
}
}
# 결과806050
댓글 영역