I am c++ developer and trying to familiarize with Core Java concepts. i found this confusing as to my final static is something it cannot be changed after the object is constructed. (correct me if i am wrong)
I came across the below implementation which i found confusing as it seems to allow value getting added into Map even when it is final static
public class MockUserServiceImpl implements UserService {
private static final Map<String, User> userMap = new HashMap<String, User>();
public static void addUserToCache(int userId, String userName) {
if (!userMap.containsKey(userName)) {
userMap.put(userName, new User(userId, userName));
}
}
}
Can someone try to explain me what exactly the static final here is meant to