- Множестенное наследие, но для интерфейсов
- Одинаковые названия метода и конструктора
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
interface Interface1 { | |
void method1(); | |
} |
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
interface Interface2 { | |
void method2(); | |
} |
Но вот для интерфейса вполне правомерно написать:
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
interface Interface3 extends Interface1, Interface2 { | |
void method3(); | |
} |
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
class TestMultipleInterfaces implements Interface3 { | |
public static void main(String[] args) { | |
new TestMultipleInterfaces(); | |
} | |
public void method1() { | |
System.out.println("Method1 works!"); | |
} | |
public void method2() { | |
System.out.println("Method2 works!"); | |
} | |
public void method3() { | |
System.out.println("Method3 works!"); | |
} | |
public TestMultipleInterfaces() { | |
System.out.println("Constructor!"); | |
method1(); | |
method2(); | |
method3(); | |
} | |
} |
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
class Test { | |
public static void main(String[] args) { | |
new Test().Test(); | |
} | |
public void Test() { | |
System.out.println("Method works!"); | |
} | |
} |
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
Compiled from "Test.java" | |
class Test { | |
Test(); | |
public static void main(java.lang.String[]); | |
public void Test(); | |
} |