I'm rewriting program from C++ to Java. In C++ I have two-dimentional array of objects and array of pointers to those objects to sort them. Not every element of the array contains object. I'm new to Java and I'm not sure how to do without pointers yet. This is the piece of code in C++:
Type ** array[SIZE*SIZE];
int k=0;
for(int i=0; i<SIZE; i++)
{
for(int j=0; j<SIZE; j++)
{
if(this->array_of_objects[i][j]!=NULL)
{
array[k] = &this->array_of_objects[i][j];
k++;
}
}
}
//then I sort
Java (wrong)
Type array[];
for(int i=0; i<SIZE*SIZE; i++)
array[i] = null;
int k=0;
for(int i=0; i<SIZE; i++) {
for(int j=0; j<SIZE; j++) {
if(array_of_objects[i][j]!=null) {
array[k] = array_of_objects[i][j];
k++;
}
}
}