有可以解决问题的朋友吗?

img

package Test;

import java.util.ArrayList;
import java.util.List;

public class A {
    private int id;

    public A() {
        super();
        // TODO Auto-generated constructor stub
    }

    public A(int id) {
        super();
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public static void main(String[] args) {
        List<B> list = new ArrayList<B>();
        for (int i = 0; i < 5; i++) {
            list.add(new B());
        }
        list.forEach(item -> {
            System.out.println(item);
        });
    }

}

class B extends A {
    private String name;

    public B() {
        super();
        // TODO Auto-generated constructor stub
    }

    public B(int id) {
        super(id);
        // TODO Auto-generated constructor stub
    }

    public B(String name) {
        super();
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}