Hey guys, i'm new to the Java and have stumbled on a few things.

When a button is clicked on my program an string is printed to a JList model.
Ex.
Snickers Bar ............$1.00

Now what i am trying to do is keep a running total of all these items and i want to use a function that finds the double within the string and then adds it to my total variable.

I'm just having trouble coming across this function that i speak of.

Any help is much appreciated! thanks

Keep the item value separate from its description. You can override toString() to provide whatever string display you wish to show, but keep the value in a separate variable in your item object. You shouldn't have to be parsing it's price out from a string.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.