Convert Collection of Primitive Wrapper Objects to Primitives


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.