I'm trying to write a simple game program. I'm having trouble with two methods, one I want to return the number of rows in the array and one I want to return the number of columns in the array. I don't know how to do this. The array is a char array and I want the number of rows to be returned as an int. I just want it to count up the number of rows (or columns) in the array and return that number. The name of the array is grid.
public int numOfColumns()
{
return grid.length;
}
I know the above is wrong because it only counts the rows, not the columns.
public int numOfColumns()
{
return grid.length;
}
I know the above is wrong because it only counts the rows, not the columns.