File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java.lang.object error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java.lang.object error " Watch "Java.lang.object error " New topic

Java.lang.object error

G. Graz
Ranch Hand

Joined: Oct 23, 2006
Posts: 30
I am bit confused on a part of code that I am working on. I am grabbing ArrayList data and then putting it into an Array to compute the average value of that Array , I keep on getting the following error message " Operator cannot be applied to double, java.lang.object" during my sum += average[i], Anyway the way I have the loop structured should be correct , I do not know what I am missing to cause the error ? Any ideas ? Thank you.

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

score is an ArrayList of Double, isn't it. Look at the API for ArrayList#toArray. Why did you declare the average array as an array of Object ?

[My Blog]
All roads lead to JavaRanch
G. Graz
Ranch Hand

Joined: Oct 23, 2006
Posts: 30
ok, thank you ! I got it ! I was a bit confused by the API when I first looked at it . Thank you again.
I agree. Here's the link:
subject: Java.lang.object error
It's not a secret anymore!