• 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

Multi Dementional Array

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok... i have this int [][] array... and i need to know how to add the columns for instance:
1 2 3 4 5 6
1 2 3 4 5 6
2 4 6 8 10 12 <<<--- i need this
can anyone help me?
thanks
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you know how to iterate through a one dimensional array? If so, post an example.
In Java, a two dimensional array is really just an array of arrays. The components of the first dimension of a two dimensional array are one dimensional arrays. So, you probably want to iterate through the first dimension (which is very much like iterating through a one dimensional array - actually it's exactly the same), get each component (remember that each component of the first dimension is a one dimensional array), then iterate through each of those arrays.
If you're familiar with iterating through a one dimensional array with a for-loop, then with the two dimensional array you'll probably want to use a for-loop inside of a for-loop. For example:
reply
    Bookmark Topic Watch Topic
  • New Topic