public static void main(String[] args) { final List<Integer> immutableList1 = Collections.unmodifiableList( new ArrayList<Integer>() { private static final long serialVersionUID = 1L; { add(0); add(1); } }); final List<Integer> immutableList2 = Arrays.asList(0, 1); Out.println(immutableList1); Out.println(immutableList2); }
public static void main(String[] args) { ImmutableList<Integer> list = new ImmutableList<Integer>() { { add(0); add(1); } @SuppressWarnings("unused") public void add2() { add(1); } }; Out.println(list); }