This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes ArrayList Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayList Problem" Watch "ArrayList Problem" New topic
Author

ArrayList Problem

Chris G Johnson
Greenhorn

Joined: Nov 20, 2004
Posts: 23
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!
Randall Julian
Greenhorn

Joined: Nov 21, 2004
Posts: 14
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayList Problem