This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have an array of size 5 integers. I have initialized 1st and third element with values 1 and 0. Now,i want to find out which all elements have i put during initialization and which are empty initially. please tell me how to do that.
int arrays automatically have all their elements set to zero, so if zero is a valid value, there is no way to check whether an element has been initialised or not - unless there is a value that you know you will never use, in which case you could initialise all elements to this when you create the array and then consider this as the uninitialised state.
You could use an Integer array. Object arrays have all their elements initialised to null. [ January 12, 2007: Message edited by: Joanne Neal ]
Raj Kumar Bindal
Joined: Apr 15, 2006
you mean to say it is impossible and there is no way to find the initialized elements.