Substring errors
843810Oct 17 2008 — edited Oct 21 2008Hello 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!