문제

This is a result of ActionListener. Depending on what he chooses in the Combo Box it returns a price. I just want it as a simple $39.99. Nothing more.

I have the

packageIndex = packageChoice.getSelectedIndex();

All the prices are in an array:

String[] prices = {"49.99, 39.99, 34.99, 99.99"}

Now I need to know how to pull the price out and display it and be able to work with the data later on. But I don't know how to pull a piece of the array out and set it to another variable.

도움이 되었습니까?

해결책

If you declare the array like:

String[] prices = {"49.99", "39.99", "34.99", "99.99"}

then you can get individual prices using:

String price = prices[packageIndex];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top