Map[] myArr, each with Integer, HashSet … can't get to HashSet (Java)?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

Thanks, there's a consensus with Dante617 that this is the way fwd – bobox Feb 20 at 19:09.

When you define your map, you could define it with the full types involved, so: private Map> myMaps = null; Then, you wouldn't have to cast it back (assuming all your maps in myMaps will be of that type).

Thank you - assumption right, so I did this - it worked! (-: – bobox Feb 20 at 19:08.

Unfortunately, Java Generics make it rather tricky to have an array of a generic class. However, it is possible, and it will solve your problem in a typesafe way. 1st.

Declare your map like this private Map> myMaps = null; 2nd. Use a utility function to allocate @SuppressWarnings("unchecked") public static T newMapArray( int size ) { return (T)java.lang.reflect.Array. NewInstance(Map.

Class, size); } 3rd. Allocate myMaps like this myMaps = newMapArray(numRepeats).

Thanks. Umm, it's early days in Java for me and that looks a plateful. I'll study it and read around the suggestion.In the meantime I'm using Map> myMaps = null; (because I understand it).

Thanks – bobox Feb 20 at 19:14 @bobox I certainly can understand why that looks intimidating. The nice thing about it is you can put it in some utility class and reuse it anywhere you like. Also, it hides the unchecked casts.

– karoberts Feb 20 at 19:53.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions