Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Substring errors

843810Oct 17 2008 — edited Oct 21 2008
Hello again all! I'm still new to this, and having a problem using strings. The code is designed to extract price from a string. Here's what I have so far:

// calculate total price
private void calculateJButtonActionPerformed( ActionEvent event )
{
double total = 0.00;
String price;

for ( int counter = 0; counter < userArrayList.size();
counter++ )
{
// convert current item to string
price = ( String ) userArrayList.get( counter );
double priceBegin = userArrayList.indexOf( "$" );

// store substring
String priceText = listItem.substring(
priceBegin );
double priceEnd = Double.parseDouble( priceText );

total += priceEnd;

}

The problem I'm having is storing the substring. The error I get now is:

C:\SimplyJava\SupplyCalculator\SupplyCalculator.java:255: cannot resolve symbol
symbol : variable listItem
location: class SupplyCalculator
String priceText = listItem.substring(

Does anyone know what I might be doing wrong?

Thanks for any help you can give!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 18 2008
Added on Oct 17 2008
2 comments
309 views