When i cast Collections.synchronizedMap( ) to hash map it returns class cast exception but when i cast Map to hash map it works fine.
As per my understanding Collections.synchronizedMap( ) also returns map .
Then Why i am getting this exception .
How to over come it.
Example code
 public class Main_1 {
  public static void main(String[] args) throws UnknownHostException, IOException {
    Map m = new HashMap();
    m.put("sachin", "sacjdeva");
     // Throws exception here 
    HashMap hm = (HashMap) Collections.synchronizedMap(m);
    //No exception
    HashMap hm = (HashMap)(m)
    System.out.println(hm);
   }
 }
Ok if its synchronizedMap and throws class cast exception can i convert this SynchronizedMap to HashMap.