When you create an arraylist of type Integer in Java what are the default values? I need to check if an arraylist is full and I was going to get the size of the array then get the value at the last index and check if it was the default value.
Is there a better way? What would be the default value?
Hope that makes sense. Cheers
int size = a.size();
int last = a.get(size);
if( last == null )
{
return true;
}else{
return false;
}
Edit;
Is it possible to create an ArrayList with a max size that you can not go over to stop it dynamically expanding? When you create an ArrayList and you use size() would that return the actual size or the amount of elements in the arraylist? When doing this to create a max size would the default values be null?
public boolean isFull()
{
int size = a.size();
int last = 0;
try{
last = a.get(size-1);
}catch (Exception e){
}
if( last == null )
{
return true;
}else{
return false;
}
}
I currently have this, how does it look? Does this make sense now?
java.util.ArrayList, or something else?