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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.