+ 1
How to print 2 d elements in array using while loop...(java)
Nested loop will aslo be used
5 Respostas
+ 1
What you tried so far.. Post that pls.. If not, try it now..
It same as 1d => a[i] as 2d by a[i][j]
Edit: yes. I try my best. Pls try first and post your try..
Giving directly code or asking code only both not good for learning....
Vedika Agrawal I can't reply via DM.. not working now..
+ 1
Ok tq ,I got it ...
0
public class Program
{
public static void main(String[] args) {
int [][] a={{10,20},{30,40,50}};
int i =0,j=0;
while ( i <a.length){
j=0;
while (j<a[i].length) {
System .out.print(a[i][j]+" ");
j++;
}
System.out.println();
i++;
}
}
}
//see comments for explanation in this code...Vedika Agrawal
https://code.sololearn.com/cSm6jciQZwou/?ref=app
0
You're welcome..