Code example for Collection

Methods: sizetoArray

0
public class ImmutableArray<T> implements Collection<T> {
 
	private final T[] _elements;
 
	public ImmutableArray(Collection<T> elements) {
		_elements = (T[]) elements.toArray(new Object[elements.size()]);
	} 
 
	public ImmutableArray(T... elements) {
		_elements = elements.clone();
	} 
 
	@Override 
	public Iterator<T> iterator() {
		return Collections.unmodifiableCollection(Arrays.asList(_elements)).iterator();
	} 
 
	public int length() { 
		return _elements.length;
	} 
Experience pair programming with AI  Get Codota for Java