Advertisement
Guest User

what the cluck

a guest
Apr 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. class MyGenericArrayList<E> {
  2. private int size; // number of elements
  3. private int index = 0;
  4. private Object[] elements;
  5.  
  6. public MyGenericArrayList(int size) { // constructor
  7. elements = new Object[size]; // allocate initial capacity of 10
  8. this.size = size;
  9. }
  10.  
  11. public void add(E e) {
  12. elements[index] = e;
  13. index++;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement