# 接口 关于接口,错误的选项是 ## 答案 ```java public interface Named{ Named(String value); String literal(); } ``` ## 选项 ### interface 可以有 default 实现 ```java public interface Parsec{ Try parse(State state); default T ask(State state) { var result = parse(state); if(result.isSuccess()){ return result.get(); } else { throw result.err(); } } } ``` ### interface 可以有类型参数 ```java public interface Parsec{ Try parse(State state); default T ask(State state) { var result = ask(state); if(result.isSuccess()){ return result.get(); } else { throw result.err(); } } } ``` ### interface 可以实现 ```java public class One implements Parsec{ default T parse(State state) { return state.next(); } } ``` ### SAM ```java public interface Parsec { public Parsec then(Parsec psc) { return state -> { this.parse(state); return psc.parse(state) } } } ```