我的教學範例: import com.google.common.collect.ImmutableList; import java.util.ArrayList; List<String> list = new ArrayList<String>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); List<String> of = Arrays.asList("a", "b", "c", "d"); ImmutableList<String> i = ImmutableList.of("A", "B", "C", "D"); import com.google.common.collect.*; ... ImmutableSet<Integer> immutableSet = ImmutableSet.of(1, 2, 3, 4, 5); ImmutableList<String> immutableList = ImmutableList.of("a,b,c,d,e,f,g".split(",")); 題外話:Scala val of = List("a", "b", "c", "d") // get only people named "Steve" from a list called "people" and sort by last name people.filter(_.firstName == "Steve").sort(_.lastName < _.lastName) |