• Post Reply Bookmark Topic Watch Topic
  • New Topic

Remove Empty location in Array with Objects  RSS feed

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How do I remove a location from a array that is empty..

I do receive a liste with object as a array and some location may bee empties.

Are some function to remove it.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once Array is initialized to particular size you can not change the array size.

So you can do like this,retrieve the element from array then check for null if not then add it to the ArrayList.

Once all the non null elements are added to the list,you can convert the list into Array using toArray method.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!