Last active
March 23, 2016 22:28
-
-
Save cobratbq/b16f3a04e36dfb3bff27 to your computer and use it in GitHub Desktop.
Example of default method in Java.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Representable { | |
String representation(); | |
default String reverse() { | |
final StringBuilder builder = new StringBuilder(this.representation()); | |
return builder.reverse().toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment