[JAVA rookie] an unknown error occurred when writing the interface for the first time.

The

code is as follows:

abstract class Animal {
    int age;
    public Animal() {};
    public Animal(int age) {
        this.age = age;
    }
}

class Bird extends Animal implements Fly {
    public Bird(int age) {
        super(age);
        System.out.println("");
        System.out.println("" + age + "");
        }
    }
    public void service() {
        System.out.println("");
    }
}

class Fish extends Animal {
    public Fish(int age) {
        super(age);
        System.out.println("5");
        System.out.println("" + age + "");
    }
}

public class Test {
    public static void main(String[] args) {
        Bird bird = new Bird(4);
        bird.service();
        Fish fish = new Fish(2);
    }
}

public interface Fly {
    void service();
}

execution problems are as follows:

clipboard.png

Jun.19,2021

public void service () has been preceded by }


clipboard.png
public void service () is no longer in class

Menu