Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with type casting

Status
Not open for further replies.

rabix

Programmer
Apr 23, 2001
12
CH
hi,



this is the way i have made the declarations

List AHVSalaryList=new ArrayList();
AHVSalaryList.add(new Double(PersonBean.getAHVSalary()));

and getAHVSalary() returns double.


double AHVSalarySum = 0.0;


but when i do AHVSalarySum=AHVSalarySum+(Double)AHVSalaryList.get(i).doubleValue();
it gives the following error.



Incompatible type for +. Can't convert java.lang.Double to double.
AHVSalarySum=AHVSalarySum+(Double)AHVSalaryList.get(i).doubleValue();
^
Method doubleValue() not found in class java.lang.Object.
AHVSalarySum=AHVSalarySum+(Double)AHVSalaryList.get(i).doubleValue();


can anyone help me?
thanx
Rabix
 
try this...

Double temp = (Double)AHVSalaryList.get(i);
AHVSalarySum = AHVSalarySum + temp.doubleValue();

If you do this it works... pain isn't it?! I hope this helped! ;-)
- Casey Winans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top