ArrayList - import java.util.Arrays; p public class...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Arrays; i public class ArrayList implements List { p private int first,last; private Object[] pin; private static final int Default_capacity=100; p public ArrayList(){ this (Default_capacity); t } public ArrayList(int cap){ pin=new Object[cap]; first=last=pin.length/2; } public int size(){ return last-first; } public boolean isEmpty(){ return last-first==0; } public boolean isFull(){ return last-first==pin.length; } public void clear(){ first=last=pin.length/2; } public boolean contains(Object obj){ for (int i=first;i<last;i++) if (obj.equals(pin[i])) return true; return false; } public Object getFirst() throws StructureEmptyException{ if(isEmpty()) throw new StructureEmptyException("The list is Empty."); return pin[first]; } public Object getLast() throws StructureEmptyException{ if(isEmpty()) throw new StructureEmptyException("The list is Empty."); return pin[last-1]; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
public Object removeFirst() throws StructureEmptyException{ if(isEmpty()) throw new StructureEmptyException("The list is Empty."); Object item=pin[first];
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/26/2010 for the course COMPUTER S Java2 taught by Professor Kwstasmixail during the Spring '10 term at Technical University of Crete.

Page1 / 3

ArrayList - import java.util.Arrays; p public class...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online