I am working on a project and I am stuck on this method public DynArray(boolean allowNulls)
.
I was wondering if anyone could help me with this method. What I have to do is create a DynArray object that may allow or disallow its elements to be null values, depending upon the value provided for the allowNulls parameter.
So far I have
public class DynArray<T> {
private static final int INITIAL_CAPACITY = 10;
private T[] theData;
private int size = 0;
private int capacity = 0;
public DynArray( boolean allowNulls ) {
capacity = INITIAL_CAPACITY;
if( allowNulls == true){
// ???
}
else {
// ???
}
}
public DynArray() {
capacity = INITIAL_CAPACITY;
theData = (T[]) new Object[capacity];
}
Can someone please point out where I am going wrong?