Notizen aus Lernsessions
This commit is contained in:
41
src/org/eidecker/oca8lernen/general/InterfaceWithFields.java
Normal file
41
src/org/eidecker/oca8lernen/general/InterfaceWithFields.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user