+ 1

How to print 2 d elements in array using while loop...(java)

Nested loop will aslo be used

25th Aug 2020, 11:47 AM
Vedika Agrawal
Vedika Agrawal - avatar
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..
25th Aug 2020, 11:49 AM
Jayakrishna 🇮🇳
25th Aug 2020, 12:08 PM
Vedika Agrawal
Vedika Agrawal - avatar
+ 1
Ok tq ,I got it ...
25th Aug 2020, 12:39 PM
Vedika Agrawal
Vedika Agrawal - avatar
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
25th Aug 2020, 12:17 PM
Jayakrishna 🇮🇳
0
You're welcome..
25th Aug 2020, 2:37 PM
Jayakrishna 🇮🇳