For example I have the next interface:
public Interface A {
String CONST = "someText";
}
I want to do something that can assemble interfaces like A. But I don’t want that my assembler-interface could override members of its parent interfaces like:
public Interface Assembler {
String CONST = "someText"; // there isn't any error
}
Can you suggest any solution?
Thanks!
EDIT: How can I deny to overlap fields from parent’s interface? (When I use field in child-interface with the same name then the compiler shows to me some error)
You can never override fields, whether
static(as in your case) or instance fields. All you can do is shadow them, but that’s just a namespacing issue; all fields will be available, just possibly through explicit qualification by type name.Whenever you need overriding, you need instance methods. In your case introduce a method that returns the proper string value. You won’t be able to implement it in an interface, though.