• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cast from Object[] to DataInfo[]

 
Laudney Ren
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
criteriaFind method returns DataInfo[].
In my implementation, I insert DataInfo into
a linked-list and use its toArray() to generate
Object[]. But I can't simply cast Object[] to
DataInfo[], so I have to use System.arraycopy.
Any better method?
 
Andre Mermegas
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure really, but i'm curious of what exactly is going on with this bit of your design, sounds awkward.
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try
(DataInfo[])ArrayList.toArray(new DataInfo[0]);
Xiaoma Wang
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, slightly more efficient, (DataInfo[])arrayList.toArray(new DataInfo[arrayList.size()]);
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic