Q:

Static methods and interfaces in Java

I Have a UserEntity class which implements the IUserEntity interface. 
In the UserEntity class I have a static map: 
private static Map<IUserEntity. IIdentifiable, IUserEntity> staticUserEntityMap = new HashMap<>();

In the IUserEntity interface I would like to write a method like that: 
public Collection<IUserEntity>      getUsers();

And in the class : 
public static Collection<IUserEntity> getUsers(){
    return staticUserEntityMap.values();
}

But I can't declare static methods in the interface and I can't change the method signature in the UserEntity class. 
How can I do this ? 

A:

In Java 8 you can have default implementations in interface but I believe that will not solve your problem.  Instead of changing the method signatures you can create a separate static method and call it with the class name within getUsers implementation.  e.g.
Create new method:
public static Collection<IUserEntity> getUsersStatic() {
   return staticUserEntityMap.values();
}

Call this method from getUsers:
public Collection<IUserEntity>      getUsers() {
  return UserEntity.getUsersStatic();
}

