How do I add 1 position and 1 position only in a 2d array. I tried adding the array value like a 1d array but multiple element were added. Can anyone help me?
This is a 2d array:
Is it possible to do this:
How do I add 1 position and 1 position only in a 2d array. I tried adding the array value like a 1d array but multiple element were added. Can anyone help me?
This is a 2d array:
Is it possible to do this:
It's not possible. Every language I know of requires matrices to be "rectangular." I would recommend either using a 2X2 matrix plus a variable, or a column or row vector of length five. You can also create a 3X2 or 2X3 matrix and just choose to leave one element as NaN or 0 etc. I may be able to answer your question better if you leave a comment telling me the reasoning behind wanting a non rectangular matrix.
EDIT: I was wrong you can create non rectangular matrices in Java link.