Java examples for java.util:List Element
as Read Only List via AbstractList
//package com.book2s; import java.util.AbstractList; import java.util.Collections; import java.util.List; public class Main { public static <T> List<T> asReadOnlyList(final T[] array) { if (array.length == 0) return Collections.emptyList(); return new AbstractList<T>() { @Override/*from w w w.j ava 2 s .co m*/ public T get(int index) { return array[index]; } @Override public int size() { return array.length; } }; } }