Created
March 18, 2019 20:01
-
-
Save AdamMc331/2f391dfc023d935fc02e928a09a1f208 to your computer and use it in GitHub Desktop.
This file contains 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
// In Java, I can do this | |
public class MainClass { | |
interface MyInterface { | |
public void printName(); | |
} | |
} | |
public class SubClass extends MainClass { | |
} | |
// Notice here that I use `SubClass.MyInterface` so the client doesn't know MainClass exists. | |
public void handleInterface(SubClass.MyInterface implementation) { | |
} |
This file contains 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
// In Kotlin, I cannot do this | |
open class MainClass { | |
interface MyInterface { | |
fun printName() | |
} | |
} | |
class SubClass : MainClass() | |
// This will not compile unless I do `MainClass.MyInterface`. See the Java notes about why I might want that. | |
fun handleInterface(implementation: SubClass.MyInterface) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment