val hm = new HashMap[String, String]()
// res1: String = bye
It seems that you are confusing the mutability of the variable
hm with the mutability of the map held by the variable, which are different.
val hm means that you cannot assign
hm to any other HashMap, not that the HashMap cannot be modified (as @nmat and @puhlen have explained).