Advertisements
how to make a datagrid mainly matrix in ajava standalone app
import java.io.*; import java.util.*; public class matrix { public static void main(String[] args) throws IOException { int[][] dim = new int[2][2]; BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the rows of matrix : "); dim[0][0] = Integer.parseInt(stdin.readLine()); System.out.println("Enter the columns of matrix : "); dim[0][1] = Integer.parseInt(stdin.readLine()); int[][] A = new int[dim[0][0]][dim[0][1]]; for (int i = 0; i < A.length; i++) for (int j = 0; j < A[i].length; j++) { System.out.println("Enter element ("+(i+1)+","+(j+ 1)1)+"): "); A[i][j] = Integer.parseInt(stdin.readLine()); } System.out.println("Matrix "); for (int i = 0; i < A.length; i++) { System.out.println(); for (int j = 0; j < A[i].length; j++) { System.out.print(A[i][j] + " "); } } } }