// *** before: ***
interface Sender {
default void sendText(String to) {
System.out.println("connect to server"); // the same code
System.out.println("text to " + to);
}
default void sendFile(String to) {
System.out.println("connect to server"); // twice
System.out.println("file to " + to);
}
}
// *** in version 9: ***
interface Sender9 {
private void connect() { // shared code, hidden
System.out.println("connect to server");
}
private static String host() { // static private too
return "localhost";
}
default void sendText(String to) {
connect();
System.out.println("text to " + to + " via " + host());
}
default void sendFile(String to) {
connect();
System.out.println("file to " + to);
}
}