Duvida ler MAp...java.lang.ClassCastException: java.lang.Integer cannot be cast to

Folks,

como recuperar o o valor do objeto String

no codigo abaixo.

Se alguém puder me ajudar agradeceria.

abs

 public  static void main (String[] args){
	    	 int max = 5;
	    	 Map m = new Cache(max);
	    	 m.put(98, new String("B98"));
	    	 m.put(100, new String("P"));
	    	 m.put(101, new String("P1"));
	    	 m.put(1, new String("A1"));
	    	 m.put(2, new String("B1"));
	    	 m.put(3, new String("C1"));
	    	 m.put(99, new String("B100"));
	    	 m.put(98, new String("B101"));
	    	 m.put(98, new String("B98"));
	    	 Iterator i = m.keySet().iterator();
			 while (i.hasNext()) {
			      System.out.println(i.next());
			      String ver = (String) i.next();
			      System.out.println(" "+ver.toString());
			  }  
	     }
} 

resultado :
100Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
	at com.cert.LinkedHashMap.Cache.main(Cache.java:38)

Prq o metodo keySet lhe retorna um Set , e sua chave é um Integer e nao um String
Ao invés de keySet utilize o metodo values(), lhe retorna uma Collection , uma outra forma de navegar no Map é utilizar Map.Entry

Folks,

estou usando KeySet pois busco ler a chave do map

e através dessa chave trazer o conteudo do Objeto (String).

mas está me dando erro se puder me ajduar …

abs

 public  static void main (String[] args){
	    	 int max = 5;
	    	 Map m = new Cache(max);
	    	 m.put(98, new String("B98"));
	    	 m.put(100, new String("P"));
	    	 m.put(101, new String("P1"));
	    	 m.put(1, new String("A1"));
	    	 m.put(2, new String("B1"));
	    	 m.put(3, new String("C1"));
	    	 m.put(99, new String("B100"));
	    	 m.put(98, new String("B101"));
	    	 m.put(98, new String("B98"));
	    	 Iterator i = m.keySet().iterator();
			 while (i.hasNext()) {
			      System.out.println(i.next());
			      Integer xave =   (Integer) i.next();
			      m.get(new Integer(xave)); 
			      System.out.println("conteudo= "+(String) m.get(xave));
			  }  
	     }


100
conteudo= P1
Exception in thread "main" java.util.ConcurrentModificationException
	at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(Unknown Source)
	at java.util.LinkedHashMap$KeyIterator.next(Unknown Source)
	at com.cert.LinkedHashMap.Cache.main(Cache.java:37)