• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object casting  RSS feed

 
Zoran Trifunovski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a list consisting of 2 objects, each object contains an Object(Type JobRunStat), Long, Long and String parameters



So, I'm doing this:




And I get:
[java] 15:33:02,453 ERROR [STDERR] java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to service.impl.JobRunServiceImpl$ReturnedObject

This is my ReturnedObject class:



with appropriate getters and setters for each field. Solutions?
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't just cast an array of objects to your specific type.

You need to read the array, and pass these values to a new instance of ReturnedObject.
 
Zoran Trifunovski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I read the values from the array? the type of the array items is Object, i cannot extract the values from a plain Object
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!