Initializing users

Report a typo

Suppose you need to write a service that stores users in memory. The service should be initialized in a custom way.

Here is a template of the service. When you start a Spring application containing this class, the application must print "init users". What changes you should make to allow it to work with this custom initialization?

Java
class UserService {
    private final Map<Long, User> storage = new ConcurrentHashMap<>();

    public void doCustomInit() {
        System.out.println("init users");
    }
}
Kotlin
class UserService {
    private val storage: Map<Long, User> = ConcurrentHashMap<Long, User>()
    
    fun doCustomInit() {
        println("init users")
    }
}
Select one or more options from the list
___

Create a free account to access the full topic