• 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

Arrays

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am having a problem with arrays. I want to put five varables in array [0]. Can this be done.



[ May 13, 2004: Message edited by: macca Mason ]
[ May 13, 2004: Message edited by: macca Mason ]
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
an array is a collection of one type of thing. each slot can only hold 1 thing. So, as written, you have a couple problems...

1) you are trying to put more than one thing into the same slot
2) the things you are trying to put in are not all of the same type.

Now, there are ways around this. You could define a class of type Car or something. this class would have as its member variables the 6 or so things you want to store (i.e. manufacturer, model, etc).

you can then make an array of Cars. once you get the six pieces of data into a Car object, you can put that into your arrray[0].
 
reply
    Bookmark Topic Watch Topic
  • New Topic