Java Android错误:无法实例化抽象类

时间:2019-07-19 08:57:55

标签: java android

我有一个要实例化的类,但是我不能,因为它给出了一个错误,该类是抽象类,而不是抽象类。

    public class Comment {

    @com.google.gson.annotations.SerializedName("postedBy")
    private Map<String, String> postedBy = null;
    @com.google.gson.annotations.SerializedName("content")
    private String content = null;
    @com.google.gson.annotations.SerializedName("location")
    private String location = null;


    public Map getPostedBy() {
        return postedBy;
    }

    public void setPostedBy(Map postedBy) {
        this.postedBy = postedBy;
    }


    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }


    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
}

实例化

Comment c = new Comment();

它给出了错误

'Comment' is abstract; cannot be instantiated 

0 个答案:

没有答案