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.
Anonymous arrays - as the name indicates the sole purpose of it has to go anonymous!
When do you want an anonymous array? An anonymous means a person with NO specific name! Similarly, an anonymous array is an array with no specific reference to it.
Here, the newly created array of Integers is referred through a reference variable 'intWrapperArray'. This is the usual practice we follow because, at a later point of time, we need the same array to be referred. It is possible only thorugh a hold/pointer/reference.
Is there any situation wherein we DO NOT need any such reference? Fine, If at all we have a situation, that's when we go for the anonymous array!
The situation is like when you want to pass an array of values (primitives or objects) but you do not really want to keep a reference to the passed values. That's when you just create an array and pass it. They can also be called as 'Just in time Arrays'. But not so sure whether such term exists or not.
Good insight there Muthu, Once an anonymous array is passed as an reference to a method it will no longer be visible to the caller unless offcourse its reference is saved in the called method. Thanks Deepak