0

I want to print the elements of a matrix but I don't know what's the problem

import java.util.Scanner; public class method3 { public static void main(String[]args) { Scanner scanner= new Scanner(System.in); int m=scanner.nextInt(); int n=scanner.nextInt(); int [][] matrix =new int [m][n]; for(int i=0;i<m;i++) { for ( int j=0;j<n;j++) { matrix [i][j]=scanner.nextInt(); } } scanner.close(); for(int i=0;i<m;i++) { for ( int j=0;j<n;j++) { System.out.print(matrix[i][j]); } } } }

30th Jan 2022, 5:13 AM
Dorsa
4 ответов
+ 2
Thanks a lot for your help. How can I insert a link in SL playground?
30th Jan 2022, 7:44 AM
Dorsa
+ 1
There is no problem with your code, it works fine. If I give the input: 2 2 3 4 5 6 It prints: 3456 Next time please insert a link to your code in SL playground, so that it is easier to test and debug.
30th Jan 2022, 5:53 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Thanks a lot
30th Jan 2022, 9:44 AM
Dorsa
30th Jan 2022, 8:54 AM
Tibor Santa
Tibor Santa - avatar