going through the web I always read something like
Java Interfaces have no state and no behavior
If you look what the common definition of state is then you likely end with
what the objects have, Student have a first name, last name, age, etc
The thing is I guess since Java 8 with their default methods I can also define some fields and use them as well as functions.
So I wonder if it's still valid to say that an interface in Java has no state and no behavior?
public interface DefaultInterface {
List<Integer> numbers = new LinkedList<>();
default List<Integer> getNumbers() {
return numbers;
}
default void addId(int value) {
numbers.add(value);
}
default IntStream perform(String string) {
return string.chars();
}
void implementMe();
}