I am attempting to implement an interface named Matrix and then perform various functions on the new Matrix objects. I cannot seemed to get passed go for this (college) assignment. When I initiate a new Matrix object and pass in a 2D array, I lose the ability to access any of the indexes in the array. I know it cannot be this difficult to implement. I haven't really accomplished anything because I cannot get go far without the ability to access the elements in the arrays. Can anyone explain how to avoid this? I can find many implementations of interfaces but can't find any that convert an array to an object and then modify the contents. I have attached the interface, as well as my (lack) of code. I have essentially been stuck between lines 2-9 because without the ability to access elements, there is no point in writing anything further. Any help would be great.
I am not sure honestly, I attempted to store a 2D array but then I have some methods below that require a Matrix return type, then I tried to change the return types to int and received an error that I am no longer implementing Matrix. I could have written this program without the interface in less than 10 minutes and I have been spending hours trying to utilize this interface to no avail. This makes me think I am missing something simple and obvious.
Your instinct to store to the 2D array was correct. Try to make just this code compile first. Then write hash code/equals/toString. Then write the other methods. That will give you a stable base to build up form.