Notizen aus Lernsessions

This commit is contained in:
2019-10-26 23:02:28 +02:00
parent a4264d38ac
commit 0141e78355
6 changed files with 207 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package org.eidecker.oca8lernen.general;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class InterfaceWithFields implements T1, T2 {
public int getT1Value() {
return VALUE_T1;
}
public int getValue() {
return T2.VALUE;
}
}
interface T1 {
int VALUE = 99;
int VALUE_T1 = 1;
}
interface T2 {
int VALUE = 98;
int VALUE_T2 = 2;
default int getValue() {
return VALUE;
}
}
class Tester {
public void interfaceTest() {
InterfaceWithFields interfaceWithFields = new InterfaceWithFields();
assertEquals(99, ((T1)interfaceWithFields).VALUE);
assertEquals(98, ((T2)interfaceWithFields).VALUE);
assertEquals(1, interfaceWithFields.VALUE_T1);
assertEquals(2, interfaceWithFields.VALUE_T2);
}
}