• 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 Problem

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am trying to create a program that makes a list of food items in an array list that can be used to create food orders. I have started on the arraylist of food items but I don't understand how to calculate the price and how to store the orders. This is the code I have so far which I know is pretty pathetic at the minute:-



Thanks to anyone who can help!
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One problem here is that the add() method, as you've used it, expects an object and cannot take a primative.

This section works because String is a class and description is an object



This part fails to compile because int's are primatives not objects:



There may be other problems, but it seems like this is the first step. You can use the Integer class instead of an int to place a numerical object in an ArrayList - it seems like situations like this are what the wrapper classes are made for.
[ November 28, 2004: Message edited by: Randall Julian ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic