This content has been marked as final. Show 7 replies
808727 wrote:Do you mean you are able to iterate through the map entrySet?
I've added about 50 class instances to a map and
im able to reference then and find names etc but i'm not able to use the object that a key represents.
im able to loop through each object
but i then want to be able to access a method for that instance, ie.
Object metricBoxInstance = (Object)m.getKey();
i then want to use metricBoxInstance.setText("for example");
Yeah tschodt, i meant Iterate.
This is my code.
mp = new HashMap<Object,String>(); //setup my map testbox = new metricBox(this,columnNames,data[i],config,columnNames[i]); //create instance of metricBox
mp.put(testbox,columnNames[i]); //add to map
Set s = mp.entrySet();
Iterator it = s.iterator();
Map.Entry m = (Map.Entry)it.next();
Object metricBoxInstance =(Object)m.getKey();
String value = (String)m.getValue();
** at this point i wanna send a set text method to each metricBox but dont know how.
metricBox metricBoxInstance =(metricBox)m.getKey();
in the first place?
mp = new HashMap<metricBox,String>();
Its simple now i see it.
I had tried that originally but it wouldn't compile.So you didn't try that, you tried an incorrect version of it. You should perserve beyond a mere compile error especially when trying the correct technique.