I have a problem where I'm supposed to expand an array, each time creating an array with identical results. Before you tell me to just use ArrayList or something else already in the Java API, I was specifically instructed to use my own code. I tried simply creating an array that is one slot larger than my current array, though that does not seem to work very well. Here is what I have that the current moment:
public static void expand(Object[] objArray) {
Object[] objArray2 = new Object[a.length + 1];
for (int i = 0; i < a.length; i++)
objArray[i] = objArray[i];
objArray = objArray2;
}