Hey,
I'm pretty new to Java and am having some trouble writing a put() method for one of my programs. The basic idea of it is to have a matrix, made by a multi-dimensional array, then to create the method with three arguements, the row, the column and the object to place into this array.
To declare the array, and the two objects I have this
Then I have a method declaration that looks like this (with x being row, y being column)
I understand that I would need to have something like,
matrixArray.put (1, 3, a)
to insert the object, but I am really lost at where to start with writing this method. Any help would be appreciated!
Thanks
I'm pretty new to Java and am having some trouble writing a put() method for one of my programs. The basic idea of it is to have a matrix, made by a multi-dimensional array, then to create the method with three arguements, the row, the column and the object to place into this array.
To declare the array, and the two objects I have this
Code:
int [] [] matrixArray = new int [5] [5]; Object a = "a"; Object b = "b";
Code:
public void put(int x, int y, Object object) {
=matrixArray(x, y, object); // This clearly doesn't work as it hasn't even been fully filled out, but is along the lines of what I'm thinking!
}
matrixArray.put (1, 3, a)
to insert the object, but I am really lost at where to start with writing this method. Any help would be appreciated!
Thanks
Comment