This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes two simple troubles. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "two simple troubles." Watch "two simple troubles." New topic
Author

two simple troubles.

ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42


The only two errors I am getting are denoted by "**********."

The first error I am getting gives me a different error message every time I modify the code. All I want is for the "prices.length" to limit "i."

The second error I am getting also tends to give me different messages. I am trying to define a variable based on an Array List. It is an int, but I need to extract values from an array list(quantities).

Any help or input anyone could provide would be great, thanks very much.
[ March 29, 2006: Message edited by: ken zemaitis ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

length is a property of the array, not a method.

try

for (int i = 0; i < prices.length; i++)

also, it would help in the future if you posted the EXACT error message you are getting with the code you are posting. those error messages tell you a lot...
[ March 29, 2006: Message edited by: fred rosenberger ]

Never ascribe to malice that which can be adequately explained by stupidity.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
i) Note that the prices is an array. To find the length of an array, you need to use the length property, not the length() method


ii) When you get something from a List, it always returns an Object. Looking at your code, it seems that you are adding a String to the array list. If that String represents an integer, you need to convert it accordingly (cast the Object to String and then convert it into an int).



Hope that helps.
[ March 29, 2006: Message edited by: Mani Ram ]

Mani
Quaerendo Invenietis
tayy abdelqader
Greenhorn

Joined: Dec 11, 2005
Posts: 20
in addition to what Mani Ram said
you have

this
taxRate = Integer.parseInt(taxRateAsString);

it must be doube

taxRate = Double.parseDouble((String)taxRateAsString);
&
reply must be initialized

hope to be helped
[ March 29, 2006: Message edited by: tayy abdelqader ]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: two simple troubles.
 
Similar Threads
Ton of problems
Error while running program
my last question for this program.
Class Help!
Errors while compiling