Posted By

kingd9 on 02/18/11


Tagged

collections


Versions (?)

Convert Collection of Primitive Wrapper Objects to Primitives


 / Published in: Java
 

  1. long[] returnIds;
  2. if (!CollectionUtils.isEmpty(ids)) {
  3. //non empty collection
  4. int count = 0;
  5. resourceIds = new long[this.selectedResources.size()];
  6. for (Long id : ids) {
  7. if(null==id){
  8. //convert nulls to 0s
  9. id=0L;
  10. }
  11. returnIds[count++] = id;
  12. }
  13. } else {
  14. returnIds = new long[0];
  15. }

Report this snippet  

You need to login to post a comment.