• 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

2 dimensional array problem

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...
i have 2 different array declared like this
1. int [][] arr1= new int kk[8][3]
2. int [][] arr2 = new int kk[10][2]

i need to compare....
if (arr[k][2]==arr2[k][0])
{
System.out.println(arr2[k][1]);
}
how do i manage the iterations for k? the array sizes are different.....
please help....
[ June 15, 2006: Message edited by: catherine matthews ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that in Java, a 2 D array is just an array of arrays.

You can use a simple counter variable for each dimension.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are standard conventions for iterating through the whole of an array. You will doubtless find them in this part of the Java tutorial.

I trust you are looking at the Java tutorial and the API documentation whenever you go anywhere near a Java editor?
 
reply
    Bookmark Topic Watch Topic
  • New Topic