Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

cast List of SelectItem to Array of SelectItem  RSS feed

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get this error:



when casting a List<SelectItem> to SelectItem[]:




Does anyone know whats wrong?
 
Tim Holloway
Bartender
Posts: 18661
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it's creating for the worst-case, but I'd have to RTFM.

I prefer this.



You may need to double-check the documentation, but the idea is that if I pre-allocate an array of the right type, I get the benefit that it will be a homogeneous array and I won't have to cast. I'm allergic to casting, even with run-time type checking.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay thanks, I wil try it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!