Wednesday, 2 October 2013

Making own java method for array length issue

Making own java method for array length issue

So I was asked in a quiz yesterday to make my own method for size of an
array of strings. I was told I couldnt use the .length shortcut. Here was
my attempt, is it right?
//doesn't receive array! because it's a datamember in the class already
public int sizeOfArray(){
int counter = 0;
while(arrayName != empty){
arrayName[counter];
counter ++;
}
return counter;
}

No comments:

Post a Comment