Hi!
I'm a java beginner and canīt figure out whatīs wrong with my code.
The question is: How do I find the first null in an array of objects, arr[10], and then add an object, obj, to that index.
I can think of something like this:
for(int i = 0; i<10; i++) { if(arr[i] == null) { arr[i] = obj; return i; //return statement because we are inside a int-method } }
I can also think of something like "if (arr[i] != null) then do nothing, else do arr[i] = obj", but I think thatīs an ugly solution.
Thankful for all kind of inputs
Hank