0

whats the problem?

import java.util.*; public class Main { public static void main(String[] args){ //i = rows , j = colomns char[][] c = { {'a' , 'b'} , {'c' , 'd'} , {'e' , 'f'} }; for (int i = 0; i < 2; i++){ for (int j = 0; j < 3; j++){ System.out.print(c[i][j]); } System.out.println(""); } } }

3rd Jul 2020, 4:10 PM
Yahel
Yahel - avatar
2 Respuestas
+ 3
Your array consists of three rows with two columns for each row. So in your nested loop you need to swap the final value for <i> and <j> for(int i = 0; i < 3; i++) for(int j = 0; j < 2; j++) Something like that ...
3rd Jul 2020, 4:25 PM
Ipang
+ 1
Ipang thanks, I thought it was the other way around...
3rd Jul 2020, 5:13 PM
Yahel
Yahel - avatar