• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Output of this 2Dimensional array ?

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i have the following code

class f
{
public static void main(String k[])
{
System.out.println("Welcome to 2Dimensional array");

int num[][]=new int[4][5];

int i,j,l=0;

for( i=0;i<4;i++)
for( j=0;j<5;j++)
{
num[i][j]=l;
l++;
}
for( i=0;i<4;i++){
for( j=0;j<5;j++)

System.out.println(num[i][j]+" ") ;
System.out.println();
}
}
}

i am getting output like this
0
1
2
3
4
.
upto 19

But i am excepting output like this 0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19

can anyone tell what is the problem ?

thanks
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

See the issue? If you don't, this should help make it clearer.
[ September 08, 2008: Message edited by: Paul Sturrock ]
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic