I would like to wirte a method called collectNums which is supposed to collect all the elements of the type Number from a 2D Object Array. Then I would like to collect all of the elements of type Number in a List and return it.
Here's my code:
public static List<Number> collectNums(Object nrAry[][])
{
    List<Number> numbers = new ArrayList<Number>();
    for(int i = 0; i < nrAry.length; i++) 
    {
        for(int j = 0; j < nrAry[i].length; j++)
        {
            if (nrAry[i][j] instanceof Number) 
            {
                numbers.add(j);
                numbers.add(i);
            }
        }
    }
    return numbers;
}
Please let me know if I have not made myself clear. Thanks everyone!
 
     
     
    