Programming: Java

Lab seven – matrices and arrays

Another handicapped lab, due to the fact that there are a bunch of students who didn’t learn matrix operation before. Add and multiply namely.

Arrays, and what are they? I also dunno the exact defination. *loL* It is simply a variable that can hold multiple instances of a particular data type / object.

when I declare it as

int[] nD = new int[5];

I just create a var that can store 5 instances of int data type and it runs from nD[0] to nD[4]; Basically 5 placeholders
to store your stuffs.

|_| |_| |_| |_| |_|

when declared as

int[][] nD = new int[5][5];

It is 5 rows of 5 placeholders each to store stuffs. cool rite?

|@| |@| |@| |@| |@|
|@| |@| |@| |@| |@|
|@| |@| |@| |@| |@|
|@| |@| |@| |@| |@|
|@| |@| |@| |@| |@|

And thus this is used to store matrix, with black representing the rows and purple representing the column. The one is green is represented by nD[2][2].

of cos I made that first [] represents rows and the second [] represents column. can be the other way round too.

Awww, got full marks for dynamic tests. Yay. Time spent:3+ hours. Majority of the time trying to find out how multiplication works for matrices.