Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ▪️Test85.java
- import java.util.function.*;
- public class Test85 {
- public static void main(String[] args) {
- // Hero85 h = new Hero85();
- // Cat85 = (Cat85 c) -> {
- // return c.getHp();
- // };
- Supplier<Cat85> supplier = () -> new Cat85();
- int hp = supplier.get().getHp();
- System.out.println(hp);
- }
- }
- ▪️Cat85.java
- public interface Cat85 {
- public int hp = 20;
- // Cat85() {
- // this.hp = 100;
- // }
- public abstract int getHp() {
- return this.hp;
- }
- }
- ▪️Error Log
- The local variable c may not have been
- initialized
- Abstract methods do not specify a
- body
Advertisement
Add Comment
Please, Sign In to add comment