0

if i have an array initialized to hold 500 objects :

Object array[] = new Object[500]

but i only populated certain number of objects in the array... ex: 300 of them

array.length will give me 500... how do i get the number of the used array? (it would be 300 in this case). is there any built in function to achieve this? thanks

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by masijade
0

You would have to keep your own count with a separate int variable.

Otherwise, you have to loop through the array and count the number of items that are not null.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.