Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java.lang.object error

 
G. Graz
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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é
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
G. Graz
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thank you ! I got it ! I was a bit confused by the API when I first looked at it . Thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic