The intention of the refactor is good. It takes verbosity out of implementors and bundle XYPosition-related methods to its own class, similar to what we do with parameter objets to avoid functions with a lot of paremeters. You are complying with the Interface Segregation Principle that states that clients should not know about methods they don't need or use.

But an interface (an abstraction) should not depend on a concretion (a non-abstract class). Both abstraction and concretions should depend on abstractions. This is called the Dependency Inversion Principle. Things that change less often (interfaces) should not depend on things that change more often (implementations) but the other way around. So my suggestion is that you make XYPosition an interface, then move the implementation to a concrete XYPosition class (choose another name).

Answer from Tulains Córdova on Stack Exchange
🌐
Oracle
docs.oracle.com › javase › tutorial › java › IandI › defaultmethods.html
Default Methods (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
All method declarations in an interface, including default methods, are implicitly public, so you can omit the public modifier. With this interface, you do not have to modify the class SimpleTimeClient, and this class (and any class that implements the interface TimeClient), will have the method getZonedDateTime already defined.
🌐
Baeldung
baeldung.com › home › java › core java › static and default methods in interfaces in java
Static and Default Methods in Interfaces in Java | Baeldung
May 11, 2024 - Furthermore, if at some point we decide to add more default methods to the Vehicle interface, the application will still continue working, and we won’t have to force the class to provide implementations for the new methods. The most common use of interface default methods is to incrementally provide additional functionality to a given type without breaking down the implementing classes. In addition, we can use them to provide additional functionality around an existing abstract method:
Discussions

java - why Interface Default methods? - Stack Overflow
To overcome that we could have ... of these default methods and then implementing class like arraylist etc could have extended that. This way we could have statisfy both java fundamentals i.e reusability and abstraction i.e keeping the interface pollution less · I am sure java 8 dev/designer have already thought about this as they are much more learned and i am missing something here. Can someone help ... More on stackoverflow.com
🌐 stackoverflow.com
Implementing two interfaces with two default methods of the same signature in Java 8 - Stack Overflow
If the method in I1 is default, ... in interface-intheritance... ... Yes exactly...It will be inherited method. ... Eclipse 2023-09 gives me the following compiler error for this: "Duplicate default methods named getGreeting with the parameters () and () are inherited from the types I2 and I1" ... This is a compile-time error. You cannot have two implementation ... More on stackoverflow.com
🌐 stackoverflow.com
Why would you use default methods in interfaces?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
17
5
November 26, 2020
What is the purpose of default methods in Java Interfaces?
Skimmed trough the article. Way too verbose and it's missing the most important reason for the existence of default methods: Backwards compatability. With default methods the language designers were able to add stream() to collections without breaking every single third party library collection. Everything else was already doable with abstract classes before their introduction. More on reddit.com
🌐 r/programming
11
0
May 28, 2023
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-8-interface-changes-static-method-default-method
Java 8 Interface Changes - static method, default method | DigitalOcean
August 3, 2022 - Java 8 interface changes include static methods and default methods in interfaces. Prior to Java 8, we could have only method declarations in the interfaces. But from Java 8, we can have default methods and static methods in the interfaces.
🌐
Medium
anushasp07.medium.com › java-8-to-17-how-interfaces-have-transformed-over-time-ed4a93771039
Java 8 to 17: A Complete Guide to Default, Static and Sealed Methods | by Anusha SP | Medium
March 16, 2025 - It can have multiple default or static methods, but only one abstract method. Functional interfaces are mainly used for lambda expressions and method references, introduced in Java 8, to write concise and readable code.
Top answer
1 of 4
20

Before Java 8, interfaces could have only abstract methods. The implementation of these methods has to be provided in a separate class. So, if a new method is to be added in an interface then its implementation code has to be provided in the class implementing the same interface.

To overcome this issue, Java 8 has introduced the concept of default methods which allow the interfaces to have methods with implementation without affecting the classes that implement the interface.

The default methods were introduced to provide backward comparability so that existing interfaces can use the lambda expressions without implementing the methods in the implementation class. Default methods are also known as defender methods or virtual extension methods.

2 of 4
14

To overcome that we could have had one class providing implementation of these default methods and then implementing class like arraylist etc could have extended that.

Your suggestion would work only for standard JDK classes (since they usually extends some base classes such as AbstractCollection and AbstractList, were the implementation of the new methods can be added).

What about custom classes that implement JDK interfaces? If, for example, you have a class that implements List but doesn't extend some JDK List implementation, you should be able to switch to Java 8 without having to implement new methods in your class.

With default implementations of new methods in the List interface, you don't have to touch your custom class. You can later add a custom implementation to those methods if you are not satisfied by the default implementation.

🌐
JavaTechOnline
javatechonline.com › home › default method in interface
Default Method In Interface - JavaTechOnline
May 1, 2025 - It doesn’t mean that both are ... still in place. We can have Default methods (method with default keyword) only inside Interfaces as of Java 8....
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › default-methods-java
Default Methods In Java 8 - GeeksforGeeks
September 6, 2025 - Java 8 introduced default methods in interfaces, allowing methods with a body (implementation). This makes interfaces more flexible and backward-compatible. Interfaces can now have both abstract and default methods.
🌐
Medium
dhruv-saksena.medium.com › default-methods-in-interfaces-java-8-56eff4c25f93
Default methods in Interfaces Java-8 | by Dhruv Saksena | Medium
September 4, 2021 - They can have only declarations, but thanks to java-8 now they can have a default implementation. You don’t need to create a separate abstract class for that purpose. Let’s say we have an interface Computable, which has a single compute method and multiple default implementations of logging-
🌐
Educative
educative.io › home › courses › java 8 for experienced developers: lambdas, stream api & beyond › default methods in interfaces
Understanding Default Methods in Java 8 Interfaces
Here, we have an interface with one abstract and one default method: ... Now we will create a class which implements the vehicle interface. ... As shown above, our class needs to implement only the abstract method.
🌐
LinkedIn
linkedin.com › pulse › default-static-private-methods-java-interfaces-incus-data-pty-ltd-sjhgf
Default, Static and Private Methods in Java Interfaces
January 26, 2024 - Adding too many default methods to an interface is not a good design. It should only be done to avoid breaking any backward compatibility when upgrading existing interfaces. From Java SE9 we can now define private methods in an interface in ...
🌐
Tutorialspoint
tutorialspoint.com › java › java_default_methods.htm
Java - Default Methods in Interfaces
Prior to Java8, an interface could have only abstract methods. Default method capability was added for backward compatibility so that old interfaces could be used to leverage the lambda expression capability of Java 8. For example, List or Collection interfaces do not have 'forEach' method declaration. Thus, adding such method will simply break the collection framework implementations. Java 8 introduces default method so that List/Collection interface can ...
🌐
Reddit
reddit.com › r/javahelp › why would you use default methods in interfaces?
r/javahelp on Reddit: Why would you use default methods in interfaces?
November 26, 2020 -

This feature has baffled me since it was released and I've not used it myself. However there is some code where I work which uses it, and I really don't understand why.

Have you ever used default methods in interfaces, and if so, why?

🌐
GeeksforGeeks
geeksforgeeks.org › java › interfaces-in-java
Java Interface - GeeksforGeeks
A class must implement all abstract methods of an interface. All variables in an interface are public, static, and final by default. Interfaces can have default, static, and private methods (Java 8+ and 9+).
Published   4 days ago
🌐
Readthedocs
java-8-tips.readthedocs.io › en › stable › default.html
11. Default and Static methods — Java 8 tips 1.0 documentation
You specify that a method definition in an interface is a default method with the default keyword at the beginning of the method signature. All method declarations in an interface, including default methods, are implicitly public, so you can omit the public modifier.
🌐
DZone
dzone.com › articles › interface-default-methods-java
Interface Default Methods in Java 8
In this tutorial, we look at how to use interface default methods in Java 8, which allows devs to add methods to the interfaces without breaking existing ones.
🌐
Medium
medium.com › @firoudreda01 › default-methods-in-interfaces-in-java-2142f938d3aa
Default Methods in Interfaces in Java | by Firoud reda | Medium
September 13, 2023 - But using default interface methods, we can add new methods to an interface that are automatically available in the implementations. Therefore, there’s no need to modify the implementing classes. ... Here, we have our Animal interface containing two default methods, "sleep" and "wake up."
🌐
W3Schools
w3schools.com › java › java_interface.asp
Java Interface
Like abstract classes, interfaces cannot be used to create objects (in the example above, it is not possible to create an "Animal" object in the MyMainClass) Interface methods do not have a body - the body is provided by the "implement" class · On implementation of an interface, you must override all of its methods · Interface methods are by default ...
🌐
Oracle
docs.oracle.com › javase › tutorial › java › IandI › interfaceDef.html
Defining an Interface (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance)
The interface body can contain abstract methods, default methods, and static methods. An abstract method within an interface is followed by a semicolon, but no braces (an abstract method does not contain an implementation). Default methods are defined with the default modifier, and static methods with the static keyword.