• 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

ArrayList

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
int[][] a = new int[][], array size u just conside some value.
Here bno, Row,Tier are 2D Arrays
for(int i=0;i<bno.lenght();i++){
for(int j=0;j<Row[i].lenght;j++){
for(int k=0;k<Tier[i].lenght;k++)
a[i][j] = Row[i][j].concat(Tier[i][k]

}

}
}

if i want to do the same thing in array list, how i can i do? For example if bno,Row,Tier are 2D Arraylist, how i can do the above mentioned operation, plz hepl me with example
 
Ranch Hand
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just create a List of List objects. For example, to have a List containing 10 Lists inside of it, do this:




So then, if I had an Integer myNumber and I wanted to insert it into the 4th element of the 7th List inside of outer, I'd do this:



But be careful not to generate an exception by adding something beyond the bounds of the list. You can get around this by using the ArrayList constructor that takes an initialCapacity, or more likely, you'll simply be calling the add() method each time to add onto the end of the List rather than explicitly setting a value at a particular point in the List.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic