I have to create in Java a 2D matrix (consisting of double values) as well as a 1D vector. It should be possible to access individual rows and columns as well as individual
You should use Vector for 2D array. It is threadsafe.
Vector> matrix= new Vector>();
for(int i=0;i<2;i++){
Vector r=new Vector<>();
for(int j=0;j<2;j++){
r.add(Math.random());
}
matrix.add(r);
}
for(int i=0;i<2;i++){
Vector r=matrix.get(i);
for(int j=0;j<2;j++){
System.out.print(r.get(j));
}
System.out.println();
}
If this is your matrix indexes
00 01
10 11
You can get specifix index value like this
Double r2c1=matrix.get(1).get(0); //2nd row 1st column
Have a look at Vector