While working on an issue recently, I came across a problem where I thought that cloning a hashmap(having some integers and strings) would solve the problem.
However when I read more about what the method does, I found that it does a shallow copy of hashmap object and the objects are not actually copied.
Hence I thought to iterate through the hashmap and call clone of each key-value pair, but i found out that
String and Integers (in fact all the wrapper classes) doesn't support clone.
My question is - why these classes don’t support clone method and what are the other intelligent ways to clone object of these classes?
Also it seems weird that clone method is object class and not in Cloneable object.
What is the reason behind this design decision?