e não consigo ler o conteudo do MAP acessando atraves
da chave…
packagecom.cert.LinkedHashMap;importjava.util.Collection;importjava.util.Iterator;importjava.util.Map;publicclassCacheextendsjava.util.LinkedHashMap{// poderia ser final:protectedintmaxsize;publicCache(intmaxsize){super(maxsize,0.75f,true);this.maxsize=maxsize;}/** * Faz com que o elemento mais velho * seja removido no caso do tamanho ser atingido */protectedbooleanremoveEldestEntry(){return(this.size()>maxsize);}publicstaticvoidmain(String[]args){intmax=5;Integercodigo=0;Mapm=newCache(max);m.put(newInteger(98),newString("B98"));m.put(newInteger(100),newString("P"));m.put(newInteger(101),newString("P1"));m.put(newInteger(1),newString("A1"));m.put(newInteger(2),newString("B1"));m.put(newInteger(3),newString("C1"));m.put(newInteger(99),newString("B100"));m.put(newInteger(98),newString("B101"));m.put(newInteger(98),newString("B98"));Iteratori=m.keySet().iterator();while(i.hasNext()){Integerchave=(Integer)i.next();System.out.println("chave="+chave);Stringconteudo=(String)m.get(chave);System.out.print(" conteudo="+conteudo);}}}resultado:chave=100conteudo=PExceptioninthread"main"java.util.ConcurrentModificationExceptionatjava.util.LinkedHashMap$LinkedHashIterator.nextEntry(UnknownSource)atjava.util.LinkedHashMap$KeyIterator.next(UnknownSource)atcom.cert.LinkedHashMap.Cache.main(Cache.java:50)