• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

2D Array Filling  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Our problem is filling the 2D Array but with different variables!!!
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. You seem to be overwriting all the contents of the array everytime you add to it. Did you mean to do this?
 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you're using your 2D array to model Car objects, so, essentially each row will model a Car, and each column will model the respective Car attributes (although it would be much cleaner, and object-oriented to simply use a single-dimensional List of Car objects, with the attributes encapsulated in the Car object itself).
Anyhow, using the 2D technique, you can have something as follows:

Realize, this is an awkward way to define Car objects, so if you need not use a 2D array, don't.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!