I face with a complex case which makes me confused,it's about how to name and access an array which its name is not exactly specified!! let me explain.
I have to build several array which their name are not axactly specified and is depends on the time which "for" block will be executed. e.g.:
here, BookBuyerAgent+i is suppose to be my array name. Then, I will have number of arrays called as: BookBuyerAgent0, BookBuyerAgent1, BookBuyerAgent2,...
now I need to have access to those arrays in another block, but I dont know even how can I make it???: what I need is some thing like this:
Of course, this snippet won't work, because any using of quoter in the code says to jvm create a new String object or get a String object from the pool. And, also, it is not possible to name variables and methods in runtime (for this you should read more about java reflections).
In java all two- dimensional arrays are not tables like in other programming languages. They are arrays of arrays. Therefore, you can make what you want by creating an array of arrays in the following way:
ya its correct and of course a better way to implement collection classes along with generics but in my opinion for a newbie at first they should have
some experience of using Collection classes(without generics).
and generics should be used, when they can understand why it is being used and when they can distinguish its effects.
Joined: Jul 06, 2009
Woow! Dear avi sinha and Alexey Saenko Thank you so much for your very complete and usefull advise!!
I love this forum!!