Skip to content

Commit

Permalink
add MyArray
Browse files Browse the repository at this point in the history
  • Loading branch information
madneal committed Dec 4, 2017
1 parent e6aa04c commit b314249
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions search/src/main/java/constants/MyArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package constants;

public class MyArray<E> {

private static final int DEFAULT_CAPACITY = 100;

private static final Object[] EMPTY_ELMENT_DATA = {};

private int size;

private Object[] elementData;

public MyArray(int capacity) {
if (capacity > 0) {
this.elementData = new Object[capacity];
} else if (capacity == 0) {
this.elementData = EMPTY_ELMENT_DATA;
} else {
throw new IllegalArgumentException("Illegal capacity " + capacity);
}
}


}

0 comments on commit b314249

Please sign in to comment.