Hello! I'm trying to write a program that will eventually carry out matrix multiplication (by another matrix and by a vector) among a few other methods for a homework assignment. However, the assignment says we first need to write a default constructor that creates the 3x3 Identity Matrix. I'm not sure how to write a default constructor. Up until now, I've written this:
public static int[][] create(int size) {
int[][] matrix = new int[size][size];
for(int i = 0; i < size; i++)
for(int j = 0; j < size; j++)
matrix[i][j] = (i == j) ? 1 : 0;
return matrix;
But this just makes an identity matrix when the user puts in the dimension (later). I know that a default constructor is what is used if nothing else specific is written for the program, but how does one write one? Is what I have at all close?