In your code,
for(int i = length; i > 0; i--) //Dead Code
{
grid[startLocX - i][startLocY] = 1;
return grid;
}
decrement in loop is never executed because in first iteration of the loop your method return a value, so never do a second iteration. Actually your code is same as:
if(length > 0)
{
grid[startLocX - length][startLocY] = 1;
return grid;
}
Hope it helps.